Sed is a command-line stream editor for filtering and transforming text.

learn more… | top users | synonyms

1
vote
0answers
13 views

Take the unknown contents of variable as literal in sed [duplicate]

I have two files: a.patterns contains patterns in a one per line way "`" "^" "<" "<(" "<)" "<[" "=" ">" "_;|^+*+?@" and b.data contains comma separated values. 1,1,0,"*",1 ...
0
votes
2answers
15 views

tab separation of the file

I have a file with seq likes this ATCGTTTCTCAGCCTTTTGGCAAGACCAAGTGTAGTATCTGTTCTTATCAGATATTGGTATCTGCAGGCACTCCTGGAACCAAT ...
3
votes
2answers
41 views

Replace uppercase to lowercase except first letter of each word in specific line

I want to replace names that I received in uppercase letters only. The names are mixed with other information which should stay as it is. AUTH: at the beginning of the line identifies it as a line ...
6
votes
3answers
149 views

sed with multiple expression for in-place arguement

I am trying to replace multiple words in file by using sed -i #expression1 #expression2 file Something 123 item1 Something 456 item2 Something 768 item3 Something 353 item4 Output (Desired) ...
0
votes
2answers
36 views

Extract multiple instances of text between two strings [on hold]

I'd like to extract text between two strings in a text file that contains Spotify chart results Text file extract: ...
0
votes
1answer
49 views

Need to swap the -(minus) sign for only numbers and not text for a given row

I have a input in which delimeter is <;| like given below:- 1-<;|3-Text <;|3.13-<;|0.28-<;|9 0.12-<;|2-Text <;|3.99-<;|4.11-<;|6 0.13-<;|3-Text ...
3
votes
1answer
58 views

sed repeating the last line in the stream

I have code in a script similar to this... smbconffile="/etc/samba/smb.conf" sed -i 's/.*[\[CMI\]]/\[CMI\$\]/' $smbconffile && echo "Success" || "Failed" sed -i 's/.*[\[LOCAL\]]/\[LOCAL\$\]/' ...
0
votes
1answer
38 views

replacing some text in square brakets in bash

I have this string that I get from running jack_lsp. a2j:Arturia BeatStep [28] (capture): Arturia BeatStep MIDI 1 in a xml file, I save the connections state from a previous jack session. ...
0
votes
1answer
18 views

How to create a file name for the pipeline to delete all files?

So I want to delete all files in my current directory using the following pipeline: ls | sed -rn 's/(.*)\.jpg$/mv -n & \1.jpeg/pi' | sh How to create a file, named so that running the above ...
3
votes
3answers
415 views

Replace %20 with a space in filenames? [duplicate]

I have a list of files that are using %20 to indicate a space in their names. I'm currently trying to do the following to change them all from %20 to a space " ". for x in *.txt do mv $x $(echo $x ...
3
votes
1answer
31 views

comparing 2 lists with additional data to be printed

I have a file lets say file1.txt ENSG00000223116 AL157931.1 ENSG00000233440 HMGA1P6 ENSG00000207157 RNY3P4 ENSG00000229483 LINC00362 ENSG00000252952 RNU6-58P I have another file say ...
1
vote
2answers
26 views

Parse command output [duplicate]

I want to only get the value associated to "cached" column of the free -m command. What is the most efficient way to achieve it? Something with sed or awk?
1
vote
2answers
25 views

Erasing in stdin all instances of regexes defined in a file

I am after something like a combination of sed 's/pattern//g' and grep -f patternfile.txt. Basically I would like the input stream to be stripped of all instances of the regex patterns defined in ...
1
vote
3answers
164 views

Replace a string and replace it with a part of itself

I am cleaning up my data that is stored in text files. Each line starts with a category label followed by the actual data that I want to clean up. There are many text files in different subfolders, so ...
0
votes
1answer
54 views

Removing contents from a file

I have a file like this >gene1*ENSG24 CTTGGGGGGCTGGGGGCCAGGTGAAAGGGAAATGGAGGGCAGCACCCGCG AGCCCTCATTGCCTATAGTGGTTTCCATGGCGATCATGTAAGAGTCAATG TCGTCATTGGCAAAGTCGTCCGGGTGGGGTGTGCTGTAGGCAGAATCGGA ...
4
votes
3answers
81 views

Insert text from file inline after matching pattern in another file

I'm trying to take the contents of a file and insert it after a matching pattern in another file using sed. My question is very similar to this question, but I wish to insert the contents of a file ...
3
votes
2answers
55 views

How do I efficiently select specific line numbers from a list of records?

I want to take a list of numbers representing line numbers of a source file I want to filter and filter those lines from the source file. How I can build a unix pipeline to extract these lines from ...
4
votes
1answer
69 views

Insert missing data within blocks

I`m a biologist and I am trying to solve this problem, please guide me on where to start. I do not know which forum to post this in, please let me know if this place is not appropriate. I have blocks ...
2
votes
2answers
90 views

Remove escape characters using sed

I have input coming from pipe which contains special escape characters. For illustration, the stream looks like this: printf "foo.bar\033[00m" > file cat file How can I remove the trailing ...
1
vote
2answers
53 views

How to get portion of lines from all .txt files in a directory?

I have 5,000 text files of journal article citations. I am trying to extract only the abstract portion. Meaning that I want to keep the same text document and delete all the other text except for ...
4
votes
3answers
211 views

“parentheses not balanced” even though I escaped it?

Im trying to run this simple sed command sed '/VALUES\ \([0-9]/d!' It still gives me an error saying "RE error: parentheses not balanced" (yes the quotes are there). What can I do? I mean I could ...
1
vote
1answer
43 views

substitute complex text string in several files that contains special characters

I need to replace a complex string in several files in a directory. The string that needs replaced is: ...
1
vote
1answer
25 views

how to move a header to the last column, using awk or sed

how to move a header to the last column, using awk or sed input file look like this: Line 1.000N x y z 23.88 44.66 56.6 23.81 41.66 53.6 Line 81.000N x y z 13.88 34.66 56.6 13.81 ...
0
votes
3answers
61 views

Strip the file base name, keep the directory part

I have a string which looks something like this dir/subdir/othersubdir/file.txt But it can also look like dir/file.txt or dir/subdir/file.txt Now, I am making a script where $P is the full ...
2
votes
1answer
39 views

sed: append line and number output

In Linux, say one wants to add the following line before line number five (thus line nuber 5 becomes line number 6) and wants to have all the lines in the output numbered throught the sed 'tool' = ...
8
votes
5answers
458 views

Convert file contents to lower case

I have temp file with some lower-case and upper-case contents. Input Contents of my temp file: hi Jigar GANDHI jiga I want to convert all upper to lower. Command I tried the following command: ...
1
vote
3answers
40 views

Splitting a string up to a specific location

I have a question and wondering how to address it with sed? How does one cut a variable up to a specific location, in my case _g? Example variable="This_is_good_g0r0s0_continues" I need to cut ...
2
votes
2answers
40 views

Combine output from df -h /dev/xvda1 into a single line

I want to convert the 2 line output from df -h into a single, meaningful line i.e. Take [root@ip-10-42-1-246 tmp]# df -h /dev/xvda1 Filesystem Size Used Avail Use% Mounted on /dev/xvda1 ...
3
votes
2answers
140 views

Sed: modify every non-first word repetition for every word in text

Can you help me to do something like that using sed? qq ab xyz ab qq aa ab Becomes: qq ab xyz +ab+ +qq+ aa +ab+
0
votes
2answers
56 views

problem with grep -f list of pattern

After searching, reading and trying possible solutions for much about grep lines with the list of patterns, hence I am writing. It is I know a very basic and have been attended in many forums. But I ...
4
votes
5answers
138 views

Use sed to print from the very first line until the line containing the last occurrence of a pattern?

I know the following commands will print up to the first occurrence of a certain pattern but will not include the later occurrences: sed -n '1,/<pattern>/p' <file> sed ...
2
votes
1answer
91 views

Replace certain text occurred within curly brackets

I have sample file as follow : WEA { Direction = Input Tag = WriteEnable PortId = "A" } MEA { Direction = Input Tag = MemoryEnable PortId = "A" } CLKA { ...
2
votes
2answers
113 views

How to replace this value in bash/sed

I need help: In my file contains the following text http://mydomain.com/test.phtml http://mydomain.com/classes/main.class.phtml http://mydomain.com/scripts/filemanager/nl.phtml i need this (i ...
0
votes
2answers
87 views

Remove a carriage return with sed

I have a large CSV file. One of the fields contains an error. This error appears as a new line in the file. Since now i've been using notepad++ with this command to correct the problem : \r";" ...
0
votes
2answers
46 views

Substituting \ for \\ in column

I exported a column of thousands of salts from Mysql for hashcat. Every instance of the character \ was replaced with a double character \\ in the exported column. Is there a way to either sed or awk ...
1
vote
1answer
44 views

How do I add something to the end of “}” if a pattern is matched?

If I have something that looks like this: hello {sdsdsdsds} pattern {askjdasjkdjasd} hello {siadsd} pattern {iuewer} So if pattern if matched before {*}, I need to add a ;. Output: hello ...
4
votes
3answers
198 views

How to change a set of characters between delimiters for exact line?

I am trying to write a script for changing user password in dovecot user database and I can't understand how to replace a set of characters between delimiters for exact lines with sed. Please check ...
2
votes
4answers
77 views

How do I use newlines inside () with sed?

When I want to replace, say Dot with Dot ##empty line## I do this: sed 's/Dot/Dot\ /g' Yes, a literal new line, this is the way it works on BSD sed. But, I can't do the same when the sed is ...
0
votes
4answers
60 views

sed remove last space only on end of line,combined with awk

I have those line Siouxsie Sioux Siouxsie Sioux ... Sylvia Tobias Sylvia Tobias ... Sydney Urshan Sydney Urshan ... Club Drummer (uncredited) Club Drummer (uncredited) ... ...
-1
votes
3answers
64 views

Removing the special character “[” using sed

I have string "[9920380315,POSTPAID,0009,646.26,SELF,APPLICATION]" in that I want to remove first "[" but unable to do this using below command, sed 's/[//g' please help
3
votes
2answers
44 views

Coloring tail output with perl

tail -f logfile.log | perl -pe 's/.*foo*/\e[1;41m$&\e[0m/g' will color all the lines containing the pattern "foo" in the logfile.log file. How can I make use of this in order to highlight ...
0
votes
1answer
51 views

sed command to print all line starting from and end to specific words present in a file

Suppose I have one file File1 consist two Words File1 : PAPER TEAM Now i need to print all the lines of a file M starting from word PAPER end to word Team sed command to print between two words ...
3
votes
4answers
303 views

How to use sed to selectively remove leading zeros

How can I substitute/remove 0's in this, using sed: 2001:0db8:03cd:0000:0000:ef45:0006:0123 to make it looks like this: 2001:db8:3cd:::ef45:6:123 There are 8 pieces of 4's divided by : in the ...
2
votes
5answers
135 views

Remove backslashes from a text file

I have Input: NISHA =\455 Output: NISHA = 455 I want to remove \ from output. I tried to use command sed "s/[\]//g" P but it is not working and it flags an error: character found ...
2
votes
2answers
263 views

Why does sed outputs “char 53: unterminated `s' command”

Why this bash script ssh $SERVER bash <<EOF sed -i "s/database_name: [^ ]*/database_name: kartable_$ME" $PARAM_FILE exit EOF output -> sed: -e expression #1, char 53: unterminated `s' ...
-1
votes
0answers
18 views

Grabbing table name from views definition using sed

I am little new to linux so please excuse me for my ignorance. I have a text file which basically lists out the view definitions in the database. What I need to know is that what are the tables ...
3
votes
3answers
33 views

Parsing Log Files with sed -e. Need to count unique class names

I have a file, let's call it filename.log, in it I have something like this (2014-11-18 14:09:21,766), , xxxxxx.local, EventSystem, DEBUG FtpsFile delay secs is 5 [pool-3-thread-7] (2014-11-18 ...
1
vote
3answers
92 views

Generate networking configuration files using sed and bash

I am a bit rusty on my scripting abilities and am trying to find a good starting point for creating a script that creates files (generating new file names) and edits the IP address in the file by ...
0
votes
2answers
39 views

how to insert backslash at the front of # symbol?

In bash programming, given a variable, say varA, that store a string containing # symbol. Let's assume varA contain this value: ASD# 1, I need to append a backslash \ at the front of #, so the output ...
1
vote
4answers
154 views

SED command not replacing (working regex)

I'm trying to replace in one of my projects all mysql to mysqli, with their parameters. To do so, I'm searching for all files with mysql in my folder recursively and replacing it with mysqli. Ex: ...