how to remove line from /etc/vfstab using shell / perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to remove line from /etc/vfstab using shell / perl
# 1  
Old 05-13-2010
how to remove line from /etc/vfstab using shell / perl

Hi,

could someone help me on this i want to remove line from /etc/vfstab in the system how to do that

it is rite now like this

/dev/vx/dsk/appdg1/mytestvol /dev/vx/rdsk/appdg1/mytestvol /mytest vxfs 3 no largefiles
/dev/vx/dsk/appdg1/mytestvol1 /dev/vx/rdsk/appdg1/mytestvol1 /mytest1 vxfs 3 no largefiles
lab1:ksh#

if I want to remove "/dev/vx/dsk/appdg1/mytestvol /dev/vx/rdsk/appdg1/mytestvol /mytest vxfs 3 no largefiles" this line how to do that

perl /shell anything will be help, but it shud be general purpose not specific to value in this example please

thxs
TaD
# 2  
Old 05-13-2010
General purpose:
Code:
sed '/pattern/d' file

Specific to the value from your example:
Code:
sed '/\/dev\/vx\/dsk\/appdg1\/mytestvol \/dev\/vx\/rdsk\/appdg1\/mytestvol \/mytest vxfs 3 no largefiles/d' vfstab

Note that these commands would not perform any "infile" changes.
You will have to redirect the output to a temporary file and overwrite the old file with that temporary file.
Better you rename your old file in e.g. vfstab.sav - after sed/before overwriting - if something goes wrong.
Hope I was clear Smilie
# 3  
Old 05-13-2010
Quote:
Originally Posted by pseudocoder

Note that these commands would not perform any "infile" changes.

You will have to redirect the output to a temporary file and overwrite the old file with that temporary file....
Here's how to do the erase and create the backup file one-shot with Perl.

Code:
perl -pi.bak -e 's/PATTERN//g' /etc/vfstab

replace the string "PATTERN" in the above code with the one pseudocoder already gave you for sed.

Why are you needing to automate the editing of /etc/vfstab? If this is a one-time deal, just open it in a text editor and remove the line. If it is not a one-time deal, what process keeps adding unwanted entries to this important system file? I would be more worried about why you are getting unwanted stuff in there, not just how to remove it.

If you edit this file incorrectly you may make a filesystem inaccessible. Make sure you know what you are erasing!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove Space and blank line from file in UNIX shell script

I have below file. I want to remove space at begining of every line and then after also remove blank line from file. I use below code for each operation. sed -e 's/^*//' < check.txt > check1.txt sed '/^\s*$/d' < check1.txt > check2.txt above code not remove all the space... (12 Replies)
Discussion started by: Mohin Jain
12 Replies

2. Shell Programming and Scripting

Need to remove first 6 lines and last line in a array ---- perl scripting

Hi I have stored a command output in an array like below @a = `xyz`; actually xyz comnad will give the output like this tracker date xxxxxxx xxxxxxx --------------------- 1 a 2 b ---------------------- i have stored the "xyz" output to an... (3 Replies)
Discussion started by: siva kumar
3 Replies

3. Shell Programming and Scripting

Perl regex to remove a segment in a line

Hello, ksh on Sun5.8 here. I have a pipe-delimited, variable length record file with sub-segments identified with a tilda that we receive from a source outside of our control. The records are huge, and Perl seems to be the only shell that can handle the huge lines. I am new to Perl, and am... (8 Replies)
Discussion started by: gary_w
8 Replies

4. Shell Programming and Scripting

Remove line breaks in csv file using shell script

Hi All, I've a csv file in which the record is getting break into 1 line or more than one line. I want to combine those splits into one line and remove the unwanted character existing in the record i.e. double quote symbol ("). The line gets break only when the record contains double... (4 Replies)
Discussion started by: rajak.net
4 Replies

5. Shell Programming and Scripting

PERL or SHELL Scrript to search in Directories by taking line by line from a text file

Unix box server version *********** >uname -r B.11.00 >echo $SHELL /usr/bin/ksh --> in this server, I have the path like /IMbuild/dev/im0serv1 ---> in that directory I have the folders startup(.jsp files nearly 100 jsp's ) and scripts(contains .js files nearly 100 files) ... (9 Replies)
Discussion started by: pasam
9 Replies

6. Shell Programming and Scripting

perl/shell need help to remove duplicate lines from files

Dear All, I have multiple files having number of records, consist of more than 10 columns some column values are duplicate and i want to remove these duplicate values from these files. Duplicate values may come in different files.... all files laying in single directory.. Need help to... (3 Replies)
Discussion started by: arvindng
3 Replies

7. Shell Programming and Scripting

How to remove particular line from file through shell script?

Hi, I am pasring a file line by line. I need to check each field in line and remove particular line. input file lines are, 02;ABC;PQR 03;aaa;rrr 04;ABC;ggg 09;eee;ABC 04;lmn;stu I am looking for line containing "ABC" as field value. Now How can I remove this line from input file... (7 Replies)
Discussion started by: Poonamol
7 Replies

8. Shell Programming and Scripting

Remove repeated line using Perl

I am new to Perl and in text file of around 1000 lines having around 500 repeated line which I felt is no use and want to remove these line.so can somebody help in same for providing sample code how can i remove these repeated line in a file. (11 Replies)
Discussion started by: dinesh.4126
11 Replies

9. Shell Programming and Scripting

Using sed to comment out line in /etc/vfstab

I am running a script remotely to do the following 1. Kill all processes by a user 2. Uninstall certain packages 3. FTP over a new file 4. Kill a ldap process that is not allowing my /devdsk/c0t0d0s7 slice to un-mount 5. Unmount /h 6. comment out the slice in vfstab 7. newfs the... (9 Replies)
Discussion started by: deaconf19
9 Replies

10. Shell Programming and Scripting

How to remove line from crontab in shell script?

Hi folks, I need to write a rollback script which removes the following line from the crontab: 0 0 * * * su - orca -c "/home/orca/core-<SCHEMA_NAME>/cleanup/CLI/cleanup_BRMS.ksh -c OC4J_RiGHTv_<SCHEMA_NAME>" <SCHEMA_NAME> is parameter. How to do it in ksh? Maybe it's better to backup the... (2 Replies)
Discussion started by: nir_s
2 Replies
Login or Register to Ask a Question