Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-06-2005, 12:37 PM
|
#1
|
Member
Registered: Oct 2005
Distribution: Slackware
Posts: 44
Rep:
|
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
|
|
|
12-06-2005, 12:55 PM
|
#2
|
Senior Member
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145
Rep:
|
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.
|
|
|
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: 7,831
|
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.
|
|
|
12-06-2005, 02:32 PM
|
#4
|
Member
Registered: Oct 2005
Distribution: Slackware
Posts: 44
Original Poster
Rep:
|
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 01:43 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|