UNIX sed command help


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users UNIX sed command help
# 1  
Old 01-29-2014
UNIX sed command help

Hi,

I am a new student learning about Unix. Can anyone help with the following sed command. What would this command do?

Code:
sed -n -e '/^s/p'


Any help you can provide would be a big help.

Thanks in advance!

Last edited by Scrutinizer; 01-29-2014 at 03:56 PM.. Reason: Formatting , code tags
dgigga
# 2  
Old 01-29-2014
The -n tells it "don't automatically print lines".
The -e tells it 'use the following string as an expression".

I think /.../p expressions mean 'print lines which match this pattern'.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 01-29-2014
Corona688 is correct. In this specific case, sed will copy whatever lines it finds on its standard input to its standard output if and only if the 1st character on the line is "s".
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed Command not working in AIX UNIX

Hi 1st problem -------------- i have this sed command in my unix script which replaces new line and carriage return in a line with the string "&#xA" the script works fine in Linux 3.0.101-0.5, but not in AIX 1 7 , the "s/\r/\&#xA/g" replacement, replaces all the character "r" in the file.... (3 Replies)
Discussion started by: maximus_jack
3 Replies

2. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

3. Shell Programming and Scripting

Using sed command replace date variable in unix

I need to use a shell script, using sed command how to replace date variable value in following format. 04/18/2012 11:38:55 Because the sed is treating the '/' as a parameter instead of the value of a variable, and hence there is the message as sed: command garbled: s/insert/04/18/2012... (9 Replies)
Discussion started by: jannusuresh
9 Replies

4. Shell Programming and Scripting

remove newline between two string with sed command in unix shellscript

I have a file (test.dat) which contains data like this 459|199811047|a |b |shan kar|ooty| 460|199811047|a |bv |gur u|cbe| but I need it like: 459|199811047|a |b |shankar|ooty| 460|199811047|a |b |guru|cbe| While reading the data from this file, I don't want to remove newline from the end of... (4 Replies)
Discussion started by: jcrshankar
4 Replies

5. Shell Programming and Scripting

invoke unix variable in SED command

Hi, I am trying tio invoke unix variable in a sed command like below, but it seems to be failing.. a=1 sed -n '$a,$p' file.txt ### Failing but a=1 sed -n '1,$p' files.txt ### Works fine Please help me to fix this... Thanks in advance (2 Replies)
Discussion started by: vjayraghavan
2 Replies

6. Shell Programming and Scripting

SED Command :: UNIX to Windows

hello people Please tell me the Windows equivalent for the SED command used in the UNIX shell scripts. In Unix this command is used to replace a string by another in a file. Thanks in Advance! (10 Replies)
Discussion started by: iim freak
10 Replies

7. Shell Programming and Scripting

Passing unix command to "sed"

I am trying a simple sed to replace a pattern but it fails ,,c an someone help in where iam wrong, here is what i run and i get no o/p a=`cat abc.sh | grep -i pattern1 | egrep -iv "pattern2" ` sed 's/`echo $a`/XYZ=newvalue/g' < abc.sh > abc.sh_new This is how my ksh -x of teh script looks... (2 Replies)
Discussion started by: yesmani
2 Replies

8. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

9. Shell Programming and Scripting

about "sed" command in unix

hi i want to append a string to some selected lines in a file. how to do that using sed? if the file looks like this hello i am here welcome to the blk hello how are you unix roollls!! windows, what is that?? i want to append string "fine" to the end of all lines starting with... (2 Replies)
Discussion started by: gopsman
2 Replies

10. UNIX for Dummies Questions & Answers

Unix "sed" command

Hello , I just wanted to know how to apend to a text in a file using "sed" command. suppose i have a text "Jaya" in the file "name". I wanted to append "thirtha" to it ,so that it displays "Jayathirtha" as a whole. Help me out. Thank You, Jay. Hi, sed -e 's/$/thirtha' <filename>... (1 Reply)
Discussion started by: Jayathirtha
1 Replies
Login or Register to Ask a Question