Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 12-06-2005, 12:37 PM   #1
Registered: Oct 2005
Distribution: Slackware
Posts: 44

Rep: Reputation: 15
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
Old 12-06-2005, 12:55 PM   #2
Senior Member
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

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

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

Last edited by gbonvehi; 12-06-2005 at 12:59 PM.
Old 12-06-2005, 12:56 PM   #3
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,818
Blog Entries: 14

Rep: Reputation: 1076Reputation: 1076Reputation: 1076Reputation: 1076Reputation: 1076Reputation: 1076Reputation: 1076Reputation: 1076
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.
Old 12-06-2005, 02:32 PM   #4
Registered: Oct 2005
Distribution: Slackware
Posts: 44

Original Poster
Rep: Reputation: 15
Thank you both. It is my plans to learn sed and awk over christmas break. I appreciate your help


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 08:22 AM
add word to each line of the file? ziggie216 Linux - General 4 04-25-2005 04:19 AM
word count in a line pantera Programming 4 08-25-2004 01:14 PM
grabing info and putting it in a file gurkburk Linux - Newbie 7 05-14-2004 10:36 AM
display full line instead of single word in for loop ken734 Linux - Newbie 3 08-15-2003 02:35 PM

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration