Questions tagged [sed]

Sed stands for Stream EDitor. It is one of the basic tools in the POSIX environment - it processes one or more files according to an editing script and writes the results to standard output. Created in Bell Labs, it has been around since mid-70s.

Filter by
Sorted by
Tagged with
3
votes
1answer
60 views

Bash script to clone directory structure with renaming

I've written a script to aid in creating new watchfaces for the awesome AsteroidOS project. A watchface there typically consists of directory structure like this: ...
1
vote
1answer
38 views

Bash script syncronizing yaml and asciidoc headers using sed

I have a bash script that fixes or creates, and syncs the asciidoc attributes and yaml header for blog posts. It does what it is supposed to. But notice I have put ...
0
votes
1answer
33 views

Grabbing resolution and offset from xrandr

(using GNU sed) I want to grab some output from xrandr and leave out everything but the resolution and offset. Input: ...
5
votes
1answer
39 views

Listing my StackEchange communities user id

Extending this answer solution, I've wrote the following bash script to get the html of my StackExchange accounts page and parse it to a YAML file. The objective ...
2
votes
0answers
68 views

Bash wrapper for connmanctl with autocompletion

So the idea came from the fact that connmanctl only completes filenames/directories when used non-interactively, whereas when used interactively (executing ...
4
votes
2answers
204 views

Bash code to install bootstrap in a Ruby on Rails repository

Wrote some code to install bootstrap (latest) in a newly created rails application. update: fixed a typo ...
1
vote
1answer
135 views

Sed script to update a version number in an RPM SPECS file

I have a specs file: Name: program Version: 2.3.3 Release: 0 ... I want to update the version number every time it's built. I perform the ...
3
votes
1answer
71 views

Bulk File Rename

A function that funnels all filenames into a file and opens that file in vim. The user then changes the names, saves, and quits. Finally the function renames the files in the folder with the new names ...
5
votes
1answer
301 views

sed to fix a messy nginx.conf

I have a few servers to fix that repeatedly get their nginx.conf file messed up due to a rogue deploy script. These are the three sed commands I'm using to fix at present: ...
9
votes
2answers
626 views

Bash script to truncate subject line of incoming email

I'm going to put this script into production in a mail server /etc/aliases file: we have a system that receives email but the subject line must be limited to a certain size. The proposed usage in the ...
4
votes
1answer
82 views

Select second field in text table with shell script

I am writing a bash script to mount openshift service accounts into kubernetes objects. The right secret to use is highlighted in this text: $ oc describe sa sa-...
5
votes
1answer
123 views

Iterate over files and convert with a new name / directory

I'm pretty new to bash scripting. I want a script that I can run in a directory that contains .md files, runs pandoc on them, and delivers the output to a sibling ...
4
votes
2answers
107 views

CGI for htpasswd registration

I decided to go with a very simple CGI user registration program to pair with Apache's mod_auth_form wrapper around a private site. It was only just after I ...
7
votes
1answer
1k views

Updating my package version using only a Makefile

So I have written a Makefile that has a release function that can be run like: make release bump=patch and I want it to be fully ...
3
votes
2answers
127 views

Bash script for managing hashtag notes

I have written a simple script for managing hashtag notes. I am not familiar with bash scripting so I would really appreciate it if someone could give me some pointers about it. ...
4
votes
1answer
71 views

Sed script that removes specific lines in `seq` output

I have a file to process with sed but I am not quite familiar with the commands with capital letters used for multi-line patterns. I use ...
3
votes
1answer
1k views

bash script - sed - template file processing

Using a bash script to process a file and pass it to AWS CLI. The script runs inside a docker container. I'm using sed to do template string replace. When MY_VALUE ...
3
votes
1answer
25 views

Accelerate set of sed commands in files (recursively over full directory)

I run this to fix some hard-coded references, replacing occurrences of mywar by clientwar: ...
3
votes
2answers
77 views

Enable or disable sections of a model according to user input

I am using sed command to comment in or out sections in my model according to user input (commenting is done by prefixing the line with !). Once this is done, I ...
4
votes
1answer
48 views

Remove every line that include and follows the second occurrence of a given pattern

From a file, I am trying to remove every line that include and follows the second occurrence of a given pattern in Bash (Mac OSX). Note, that a file may have only one match of the given pattern (and ...
4
votes
1answer
83 views

Try every option for a command and make anagrams out of the successful ones

What I have: I am trying to find what words you can make out of Linux command options like ls -cat or ps -elf. To do that I am ...
7
votes
3answers
6k views

Transform snake_case to camelCase with sed

I want to convert my_long_variable to myLongVariable in sed. This works: ...
4
votes
2answers
40 views

Isolate URLs from other text around it and put each on own line (with sed)

I have a small shell script that uses sed to take an input file of URLs with hand-written notes around them and strips the notes and puts each URL on its own line. ...
0
votes
1answer
37 views

Loading a file in vim via piped output of ag

I feel as if my scenario is fairly simple but that I might be overcomplicating it. I am searching through files looking for a special condition, that is where the method ...
2
votes
1answer
679 views

Finding hidden field values in a web page before submitting a login form

In order to submit a login form using wget, I need to find the values for the hidden field that were added to the form recently. Grepping for the names gives the ...
4
votes
0answers
88 views

SLOC Counter Script Optimization

I'm a HPC guy so I'm all about "make it work, then make it fast." I have a little bash script which gets a Physical Source Lines Of Code (PSLOC) and Logical SLOC (currently just of Java code, but it ...
3
votes
1answer
42 views

Removing ASCII "frame" around text

I sometimes save nice fortune outputs to my Evernote. The data looks like this: ...
4
votes
2answers
2k views

Using sed regular expression to extract domain name from file

I'm learning regex with sed to extract the last field from file named "test". The method I'm trying gives desired output. Please suggest if this method Im trying is ...
3
votes
1answer
70 views

Remove line numbers from shell history

I want to parse Linux history output and the commands parts only (without numbers): ...
3
votes
2answers
36 views

Changing filename and copying in bash

I wrote a script which changes names of last downloaded songs and copy them to music directory. Can it be written better? ...
2
votes
1answer
70 views

Parsing logs in sed efficiently

I have an application which log file has most lines start with a time/date, followed by a debugging level and the actual log message. Often I want to watch the output live and colors make it a lot ...
3
votes
1answer
119 views

Changing cuts to sed for parsing dates from apache log (common log file)

Would switching my cuts below to SED improve performance? I am trying to get a per date count of requests for the last two weeks from a server log. The script runs, but slowly (comes in around 14 ...
4
votes
1answer
250 views

Using sed to implement the cp command

I have a script for school that mimics the cp command. Part of the assignment is to modify the script so that the while loop (that assigns ...
4
votes
1answer
204 views

Find-grep-sed for project-wide search & replace

I always forget how to do this efficiently with Vim's arglist. Drawing inspiration from a post over at Stack Overflow, I wrote a Bash function to perform a project-wide search & replace. It does ...
6
votes
1answer
136 views

Bash script to convert NIST vectors to debug scripts

TL;DR: The Bash script converts a published, somewhat-structured text file into a format usable by my testing infrastructure. It's slow, I think it's ugly -- although it is fully functional. The NIST ...
4
votes
1answer
73 views

Extracting performance statistics from FTP session transcript

I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd ...
4
votes
1answer
2k views

Bash Shell Script uses Sed to create and insert multiple lines after a particular line in an existing file

This code seems to work, but I'd like someone with shell-fu to review it. Is the temp file a good idea? How would I do without? Is sed the right tool? Any other general advice for improving my shell ...
1
vote
1answer
203 views

Parsing of a file using sed

I have a file containing lines having this structure : ...
1
vote
2answers
188 views

Add getters and setters to a set of variables [closed]

Any improvements are welcome. a.bat ...
2
votes
2answers
754 views

Adding a zero to file names

I've recently discovered the power of sed; regular expressions seem like they'll take a lifetime to master. This tiny script uses both to add a zero before the single digit in file names. Can this be ...
4
votes
1answer
561 views

Transpose a matrix using sed

I'm trying to transpose the following data from: ...