LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-29-2006, 09:32 AM   #1
camaroblue87
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Rep: Reputation: 0
Sed substitute for my username?


Hi everyone, i have been stuck on a problem that i cant seem to find an answer for, i tried many things that didnt work.

the problem is:
[ list all your processes, using sed to substitute "me" for your username.]

So i am asuming that after i get the right sed command i will be able to do something like [ ps -u me ]

this is what i have tried so far and they have not worked

Code:
sed 's/s06-cs271-s09/me/g' </home/s06-cs271-s09 >/home/s06-cs271-s09.new

sed 's/s06-cs271-s09/"me"/g' sedtest.txt
any help would be greatly appreciated, thanks
 
Old 04-29-2006, 11:07 AM   #2
burninGpi
Member
 
Registered: Mar 2006
Location: Fort McMurray, Canada
Distribution: Gentoo ~amd64
Posts: 163

Rep: Reputation: 30
try this:
Code:
ps -ux | sed "s/\$$USER/me/"
the \$ guards the RE so if your username is in the command, it doesn't get substituted also. using $USER makes the script shorter, and the "g" flag is unneeded. Put this script in your path (eg ~/bin/pssub):
Code:
#!/usr/bin/sed -f
s/$USER/me/
chmod 755, and you can run it with
Code:
ps -ux | pssub
 
  


Reply



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
Substitute Firewall for FC Linux31 Fedora 3 06-11-2005 02:07 PM
useradd: invalid username username$ engyeow Fedora 5 12-05-2004 04:35 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM
Could there be a substitute of VB in RH Linux Alasis Linux - Software 3 09-10-2002 04:55 PM
MS Access Substitute bobcl Programming 5 01-21-2002 10:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:22 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration