Sed is known as a Stream Editor in that it can carry out various filtering and/or transforming functions on standard input or on user specified files.

learn more… | top users | synonyms

0
votes
0answers
23 views

Using sed to remove all lines containing special characters , numbers, and spaces

So I'm fairly new to using shell--bash specifically--and I'm in the process of writing a script which will translate files containing DNA sequences into a more useful format. Unfortunately, many of ...
1
vote
1answer
57 views

diffrence between two files of different row numbers

Yesterday I asked this question, and got awesome answers, it's really a joy to ask questions on this site. Today I got a slightly different question say I have csv1 1,2,3,4 5,6,7,8 -- 9,10,11,12 ...
0
votes
4answers
46 views

Adding a number to a already present variable sed/grep/awk

I have this in file.txt FORM: lookupfile Version: 1 LookupFile:"$i" How can I find this in the file and add a variable b to the $i. So example INPUT FORM: ...
9
votes
5answers
626 views

Difference of two big files

I have "test1.csv" and it contains 200,400,600,800 100,300,500,700 50,25,125,310 and test2.csv and it contains 100,4,2,1,7 200,400,600,800 21,22,23,24,25 50,25,125,310 50,25,700,5 now diff ...
4
votes
6answers
442 views

Grep beginning of line

I have a file with the following contents: (((jfojfojeojfow // hellow_rld (((jfojfojeojfow // hellow_rld How can I extract every line that starts with a parenthesis?
-2
votes
4answers
59 views

Copy a string occurring before a particular pattern.

I am to copy this emuEventTrapInformative from below. -- Traps emuEventTrapInformative TRAP-TYPE ENTERPRISE compaq VARIABLES { scellNameDateTime, shelfId, ...
2
votes
3answers
54 views

Delete multiple lines from file when text is found

I've seen multiple answers to delete a single line with sed or grep, but I'm in need to search for a line, delete that one, and the 2 proceeding lines. For example, in the file ~/.profile I have lines ...
0
votes
3answers
49 views

Print a string a number of times [closed]

I have a variable numvar which contains a number. CODE something that reads number stored in numvar and then creates the same number of sTrapValue[with a number here that incrementally ...
-2
votes
2answers
60 views

Delete lines between 2 strings

I am to delete all stings from starting of file to a certain point using anything, sed, Grep, awk in shell INPUT sCSISmart20 TRAP-TYPE ENTERPRISE cyclone ...
2
votes
5answers
107 views

Condition that matches all occurrences of a word in a file ad does something

I am to do something like this for (( every occurrence of the word TRAP-TYPE in a file )) do desc="$(< inputfile awk '/DESCRIPTION/ {getline; gsub(/^\s*"/, ""); gsub(/"\s*$/, ""); print}')" ...
-1
votes
2answers
114 views

Copying some parts of file

I am to copy "SNMP Agent is up" and "::=101" and count the number of variables present (example here there are 5) and put them in 3 Different variables. FROM FILE.TXT sCSISmart1 TRAP-TYPE ...
3
votes
5answers
198 views

sed remove last 2 numerals

I have the following. oid=.1.3.6.1.4.1.795.2.5.0.xxx (these 0.xxx represent any random numeral) I want to do the following echo $oid | sed (some commands to remove 0.xxx) and store the resulting ...
3
votes
3answers
223 views

How can I cut email addresses with sed?

I have the following emails.txt with: tsar@gmail.com c2m_@hotmail.com.es c72@hotmail.com.es.com;es m7_@hotmail.es.com cm_@hotmail.com @pepito.com And a sed command to get sed -n -r ...
2
votes
3answers
206 views

How to delete lines starting with certain strings

Is there a way to delete lines starting with certain strings. I have this youtube-dl code youtube-dl --extract-audio --audio-quality 0 --newline --audio-format mp3 ...
3
votes
1answer
78 views

youtube-dl file download progress with zenity progress bar

How to add youtube-dl file download progress percentage to zenity progress bar sample code (just an example, not a working one) #!/bin/sh ( progress=$(youtube-dl --extract-audio --audio-quality 0 ...
1
vote
2answers
43 views

Copy particular text from one file to other using GREP or SED

I am to copy the number 795, and use it another file. This 795 could be any number and can change from file to file. Everything till the enterprises will remain the same even the ending curly ...
-1
votes
2answers
23 views

Sed script to print a variable based on user input

I want to write a sed script that reads user input, and if the variable matches a predefined string it should print welcome, otherwise it should print sorry. For example, if user inputs "Hello" the ...
2
votes
5answers
211 views

Use sed command to apply a condition to check if a pattern has been matched

I am searching for the string ::=BEGIN and I want to apply a condition to check if the word has been found. So, what I mean is something along these lines: if (sed command does find a match for ...
3
votes
4answers
497 views

What kind of space character is this?

This is pretty weird, using a .txt document sent by a friend using Windows, I believe I have found a weird space character. If I run cat file the character appears as �� Also, I was running if [[ " ...
0
votes
3answers
53 views

Grep for a pattern in line

How can i grep for a specific pattern of numbers like 1000010000000 in a whole file - the line has to have thes numbers at the beginning not somewhere else...
1
vote
3answers
102 views

Using sed to add text to a file before and after word

I have a file with words, one word per line, which I now want to change so that is becomes a .sh-file with an egrep-search string for each word. The search string I want in the end looks like this: ...
1
vote
1answer
29 views

Parse file for recursive pattern

in my dir there are several files with the pattern simulation_y_t for all files with this pattern I would need to check whether in the last line of the file the word hgip comesup or not ...the ...
-3
votes
1answer
29 views

Which is the most efficient search and replace tool? [closed]

Asking out of curiosity, which is the most efficient/fast "Search & Replace" text tool? awk or sed or any other?
4
votes
1answer
163 views

Delete lines in several files in a folder once (avoid infinite loop)

I have several files in one folder, and I want to delete the first lines in all of them. If I do this: sed -i.bak '1,2000d' *.dat the first 2000 lines are deleted, but then the filename is still of ...
2
votes
6answers
226 views

How can I extract text between a pair of the same character?

Input: blahŤfoobar1Ťblah Desired output: foobar1 I want to get the text between two "Ť" characters. Assume there will always be either 0 or 2 "Ť" characters, to make things easier. I tried the ...
3
votes
2answers
175 views

changing string with sed, where did it go?

$ cat test-paths.txt test/sub2/configuration.php test/sub3/configuration.php test/configuration.php test/sub1/configuration.php $ cat find-host-test #!/bin/bash for i in `cat test-paths.txt` do ...
1
vote
1answer
37 views

How to update the multiple files without changing file date?

I have replaced word 'merchant' to 'capital' in files founded in the current directory using following command: find * -type f -exec sed -i -e 's/merchant/capital/g' {} \; but above command will ...
1
vote
0answers
21 views

sed single qoutes, double qoutes, delimeters [duplicate]

I am confused a little bit. I would like to swap 2 directory in the apache2 config files with the sed program. APACHE_CONF=/etc/apache2/apache2.conf FULL_DIR=/home/$USER/new ...
3
votes
2answers
52 views

Automatically doubling the value of numbers in a string in multiple files

I'm trying to modify Java source code in numerous .java files that contain strings similar to this: private static final Height biomeHeight = new Height(0.1F, 0.2F); There are over 75 and I'd like ...
2
votes
2answers
47 views

How can I put a cluster lines in numeric order?

How can I convert this: -foo -bar 42 \ randomtext=00 "00" \ -randomtext=00 "00" \ -foo -bar 104 \ randomtext=00 "00" \ -foo -bar 1 \ -randomtext=00 "00" \ To this: ...
5
votes
8answers
532 views

How can I delete text that is NOT in quotes or parentheses?

Input: 19. "foo foo" (bar bar) (19) raboof "foo foo" raboof Expected output: "foo foo" (bar bar) (19) "foo foo" As you can see, I would like to keep the double quotes and parentheses. ...
3
votes
3answers
192 views

Regex Conversion

I'm wanting to make a command to edit /etc/default/grub and change the timeout from 10 to 2. Could anyone explain how to do this?
17
votes
5answers
409 views

How can I merge files on a line by line basis?

cat file1 foo ice two cat file2 bar cream hundred Desired output: foobar icecream twohundred I already have a solution involving a for loop with sed using the line number of the files, but in ...
4
votes
4answers
342 views

How can I extract text between parentheses containing a specific word?

How can I convert this: foo (blah) (bar 80) foo (cats) (blat 92) To this: foo bar 80 foo blat 92 I would like to keep all the text that is NOT in parentheses. I only want to extract text ...
6
votes
5answers
347 views

How can I edit a range of text between 2 symbols? awk, sed, regex

Using the "*" symbol, (doesn't have to be that one, any special character will do in order to indicate), how can I edit the text from this: *berry straw rasp blue boysen * blahblah blahblah blahblah ...
1
vote
1answer
26 views

What'd be a good SEd trick to list the properties of all X input devices?

A list of X input devices is returned using the command xinput --list and the properties of an input device are listed using a command of the form xinput --list-props "device name". How could SEd be ...
0
votes
2answers
30 views

how to use of sed command to search string with “/” character in it and replace with some other string?

I have run the command: sed 's/http:\/\//www/' filename In output,this command didn't replace "http://" with "www" why? and how to change delimiter in sed command?
10
votes
2answers
1k views

What does this 'apt-get remove' instruction do?

What does the following code do? I found it on internet so I copied it and pasted it into terminal but when I installed a new kernel it only detects the old one. sudo apt-get remove --purge $(dpkg ...
1
vote
2answers
94 views

Running a command in screen daemon mode

I am trying to run a command in screen mode using the command screen -dmS screen_name sed -i 's/a/b/'g some-file.txt Nothing happens. When I put the same command in a script and run the command: ...
1
vote
3answers
67 views

Edit text iteratively within a file using commands

I am a new Ubuntu user. Please help me in solving the following problem: My input text file is -0.716425 -12.8939 -3.3341 -7.38497 -2.62709 3.00437 -6.69861 -13.8853 -5.81095 -7.37465 ...
2
votes
1answer
65 views

sed to execute a command as replacement with substitution pattern as argument

I am trying to replace time in a log file by: cat mlog.log | sed -e "s/^[0-9\.]*/\$(date -d @&)/" Why it always first execute $(date -d $&) but not doing replacement at first and then ...
4
votes
3answers
211 views

Reverse sed's/regexes' pattern-matching priority order

Consider this command: echo "string.with.dots" | sed 's/\(.*\)\.\(.*\)/\1\n\2/' (Matches into a first capturing group any character until the last . and into a second capturing group any character ...
3
votes
4answers
269 views

What is a practical way to list every character used in a file (Bash) (Regex)

How can I turn this: Johnny's penguin, (Tuxie), likes the following foods: French fries, and beef. To this: abcdefghiklnoprstuwFJT',():. (These are the total characters used in the input) ...
1
vote
1answer
83 views

How to filter out links from html using grep or sed?

I am trying to filter the links related to the src attribute from the html of a web page. I used curl to get the html and below sed command to filter the url links. curl -s http://www.example.com/ ...
0
votes
0answers
42 views

sed error Bash script

So here's the deal I'm trying to do some auto editing of a file with sed in a bash script. Here's my code: systemdate=$(date) sudo mkdir "/tmp/autoupdate" sudo echo "$systemdate" > ...
3
votes
4answers
137 views

Replace string with multiline file content

I need to replace string SALT in a file with content of another file. Problem is that the input file has multilines. I tried something like this in my bash script: SALT=`cat salt.txt`; sed ...
3
votes
4answers
85 views

Find and replacement of the numerical part of a particular string with increased value using terminal command [duplicate]

The inputfile is, test00.dat test07.dat test03.dat aram22.dat test09.dat aram09.dat test13.dat I need the output file as test01.dat test08.dat test04.dat aram22.dat test10.dat aram09.dat ...
3
votes
3answers
212 views

How to label occurences of text?

I would like to convert blue blue red green to: color.1=blue color.2=blue color.3=red color.4=green Any leads on how to tackle this? sed, awk, etc.?
0
votes
2answers
56 views

How to highlight second vowel from every word in a file?

I am trying to highlight every second vowel in a word to the colour red. What am I doing wrong? cat room.txt | sed 's:[AEIOU]:$(printf "${\e[1;30m}&${\e[0m}"):i2' Ps. Sorry for making it ...
2
votes
3answers
117 views

How do I extract a single attribute from an XML file?

I'm not really familiar with regex, sed, etc. and a bit lazy to figure it out right this moment, so how do I extract this line: <yweather:astronomy sunrise="6:50 am" sunset="7:06 pm"/> Let me ...