![]() |
Need sed to uncomment fstab file lines.
Can somebody please give me an example of the sed code that could uncomment a drive mount line in fstab?
|
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. |
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 |
check out regular expressions and/or http://www.student.northpark.edu/pem...d/sed1line.txt
|
Nice link. Thanks, IR.
|
OK. How does this look?
sed 's/\(#\)\(/dev/sde1.*\)/\2/' /etc/fstab sed 's/\(#\)\(/dev/sdf1.*\)/\2/' /etc/fstab |
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. |
Quote:
sed -i 's/\(#\)\(\/dev\/sde1.*\)/\2/' /etc/fstab |
It works without the -i. I would leave it as is.
|
| All times are GMT -5. The time now is 3:11 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC