- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- replace multiple strings in fstab
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2008 10:46 PM
09-17-2008 10:46 PM
replace multiple strings in fstab
I am very bad in scripting and I need to change 50 entries in a file from lets say
pqr23 to pqr23/abc
pqr24 to pqr24/abc
-----
pqr78 to pqr78/abc
how can we do it....
BR,
Kapil+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2008 10:51 PM
09-17-2008 10:51 PM
Re: replace multiple strings in fstab
cp /etc/fstab /tmp/fstab
# make a backup
vi /tmp/fstab
:%s/pqr78/"pqr78/abc"/g
Repeat for other changes.
Also sed can be used this way.
http://nl.ijs.si/gnusl/tex/tunix/tips/node220.html
http://student.northpark.edu/pemente/sed/sed1line.txt
http://forums.digitalpoint.com/showthread.php?t=24956
http://lowfatlinux.com/linux-sed.html
A few low fat examples.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2008 10:54 PM
09-17-2008 10:54 PM
Re: replace multiple strings in fstab
Is there anyway I can do it in one shot.
BR,
Kapil+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2008 11:39 PM
09-17-2008 11:39 PM
Re: replace multiple strings in fstab
like pqr23 abncjfh
so I canged
abncjfh to /abc abncjfh
bad idea but it worked.
I have one more question I need to add a word mns in line number from 31 to 35.
How can we do that.
BR,
Kapil+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2008 12:11 AM
09-18-2008 12:11 AM
Re: replace multiple strings in fstab
I don't know how you want to add it (at the beginning/at the end/as a new line?)
and my scripting experience is still at the beginning, but I think 'awk' would do what you want.
Check 'man awk' and search for examples here.
I've an example for sorting a file except the first 2 lines:
cat
For your changing I would have used 'sed'
It's like:
sed 's/string1/string2/g' /etc/fstab > /etc/fstab.out
For the additional '/' in your string2 I believe there's something like '\/', but this you would have to search too.
HTH
Volkmar
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2008 12:51 AM
09-18-2008 12:51 AM
Re: replace multiple strings in fstab
command is
12,15s/$/abc
will append abc at end of file.
Thans for the help,
BR,
Kapil+