![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2004
Posts: 8
Rep Power: 0
![]() |
Can somebody please give me an example of the sed code that could uncomment a drive mount line in fstab?
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
Is it a particular line you are interested in? Are there other commented mounts that you want to exclude? What does your fstab look like?
To remove all # in the file you could do this: cat fileA | sed 's/#//g' > fileB; mv fileB fileA If you want a more specific line uncommented, need more info.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Sep 2004
Posts: 8
Rep Power: 0
![]() |
Quote:
There are two lines that need to be uncommented and a few others that need to stay commented. The two that need uncommenting look like this: #/dev/sde1 /vmware/tol ext3 nosuid 0 0 #/dev/sdf1 /vmware/sas ext3 nosuid 0 0 |
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
check out regular expressions and/or http://www.student.northpark.edu/pem...d/sed1line.txt
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Professional Programmer
|
Nice link. Thanks, IR.
__________________
Amateurs built the ark Professionals built the Titanic |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Sep 2004
Posts: 8
Rep Power: 0
![]() |
OK. How does this look?
sed 's/\(#\)\(/dev/sde1.*\)/\2/' /etc/fstab sed 's/\(#\)\(/dev/sdf1.*\)/\2/' /etc/fstab |
|
|
|
|
|
#7 |
|
Programming Guru
![]() ![]() ![]() |
My shell responds with:
sed: command garbled: s/\(#\)\(/dev/sde1.*\)/\2/ You need to escape the / character... like this: sed 's/\(#\)\(\/dev\/sde1.*\)/\2/' /etc/fstab sed 's/\(#\)\(\/dev\/sdf1.*\)/\2/' /etc/fstab The only difference is the sde vs sdf... regular expressions would allow you to process them with just one line. But if its a one time execution, save yourself the trouble. You're welcome PoM... There is another one for Awk floating around somewhere.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#8 | |
|
Newbie
Join Date: Sep 2004
Posts: 8
Rep Power: 0
![]() |
Quote:
sed -i 's/\(#\)\(\/dev\/sde1.*\)/\2/' /etc/fstab |
|
|
|
|
|
|
#9 |
|
Programming Guru
![]() ![]() ![]() |
It works without the -i. I would leave it as is.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem processing file into a char array | csrocker101 | C++ | 1 | May 8th, 2007 11:50 PM |
| converting string to float | beginnerCCC | C | 22 | Oct 2nd, 2006 11:59 PM |
| OnlineTextEditor.Com! | Sane | Show Off Your Open Source Projects | 43 | Jun 16th, 2006 8:55 AM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |