LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   putting word in front of each line in a file (http://www.linuxquestions.org/questions/slackware-14/putting-word-in-front-of-each-line-in-a-file-389885/)

stryka 12-06-2005 12:37 PM

putting word in front of each line in a file
 
Hi, I have a list of suid programs in a file, and I am trying to figure out how I could go about echo'ing a specific phrase in front of every line in the file. More specifically, "chmod go-r"

Can someone assist me? Thanks

gbonvehi 12-06-2005 12:55 PM

Code:

sed -e "s@^@chmod go-r@" -i file
or if you're used to /

Code:

sed -e "s/^/chmod go-r/" -i file
:)

MensaWater 12-06-2005 12:56 PM

awk '{print "chmod go-r",$0}' <filename>

The text inside the quotes is literal. $0 represents an entire line. The comma puts a space between the literal text and the line.

stryka 12-06-2005 02:32 PM

Thank you both. It is my plans to learn sed and awk over christmas break. I appreciate your help :)


All times are GMT -5. The time now is 08:05 PM.