LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 12-06-2005, 12:37 PM   #1
stryka
Member
 
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
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

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

Code:
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
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,008
Blog Entries: 5

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
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
stryka
Member
 
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
 
  


Reply


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:03 AM.

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