I guess you can't use selective printing when combining multiple sed commands.
Incorrect. You can use -n with multiple -e options.
Quote:
Originally Posted by millan
-e option is used when you want to output as for example text1 OR text2.
You can not use this option for text1 AND text2.
For AND, You have to use pipe in between two sed command.
Nonsense. -e has nothing to do with OR'ing or AND'ing. It's no different than putting all of the arguments of all of the -e options into a file and using -f to read the script.
Quote:
Originally Posted by ragilla
Hi i am facing problem with sed -n option could you please help me on this, i have a file test the contents of the file is
the above content is present in one line, so i have written code to separate
output of the above command is
according to last part of sed command it should print only the lines which have word "pdf" in it , but its not happening its printing lines which doesnt have "pdf" also so please help me to understand what i was doing wrong
The problem is that you misunderstand what /pattern/ matches against. It does not match against a line; it matches against the pattern space. The pattern space is where sed places whatever it has just read. Usually, the pattern space only holds a single line, but after your first substitution command, which replaces each instance of </a></td> with a newline, the pattern space may contain multiple lines. So, /pdf/p prints the entire pattern space (which may consist of multiple lines) if the string pdf is present anywhere in the pattern space.
Could someone please help me with the following.
I'm trying to figure out how to delete two words within a specific file using sed.
The two words are directory and named.
I have tried the following:
sed '//d' sedfile
sed '//d' sedfile
both of these options do not work.....
... (4 Replies)
Folks,
I've been trying to use the ENV variable with slashes(/) in its value inside the sed substitution..
Sed 's/myval/'$MYVAL'/' file1 >> file.tmp
If MYVAL=<sometext>, it works.
if MYVAL=/home/venkat, it doesnt.
***************************
bash-2.05$ export VAL=/home/venkat... (5 Replies)
Hi,
Please tell me how to use insert option of sed in a shell script on Solaris/AIX plateform.
For example I need to insert few lines on top of every file whose name starts with say "SOL_DEL".
Thanx. (2 Replies)
hello. i have a script, but in solaris i get this message sed: illegal option -- i
whats wrong? With Ubuntu there is no problem. Thanks for help.
#!/bin/bash
for file in $(find /directory..../Test/*.txt -type f)
do
head -n 1 $file | egrep '^#!'
if
then
sed -i '2i\Headertext'... (3 Replies)
I have tried doing this to delete some lines: sed '1,10d' file
Now I want to specify a variable as a line number for example:
lastline=wc -l file
linestart=$lastline - 20
sed '$linestart,$lastlined' file
but this will give error: sed: -e expression #1, char 3: extra characters after... (4 Replies)
Hi,
What does the following command do on files?
sed '1b; $d'
To me it just deletes the last line of the file. If so what is the significance of sed's 'b' option?
Thanks (1 Reply)
Hi,
I am aware that the below are the equivalent in sed for cat command.
sed ':'
sed -n 'p'
Is there any way to emulate the same using "q" option in sed?
Thanks (8 Replies)
sed "s/^/8,A1,$dat,id2_3,/g" -e sed "s/$/,,,,,,,,,,,/g" temporary
wn m running this script m getting a error... plz help me with this....
O/p
sed: -e expression #1, char 3: unterminated `s' command
---------- Post updated at 11:35 AM ---------- Previous update was at 11:33 AM... (7 Replies)
Hi,
I have the following command.(Delete all trailing blank lines at the end of a file.)
sed -e :a -e '/^\n*$/{$d;N;ba' -e '}'
I don't understand the logic of this command and also I don't understand why -e is used.
Can you please let me know the logic of this command and why three -e... (5 Replies)