add a line at the end of a file using shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting add a line at the end of a file using shell scripting
# 1  
Old 09-19-2008
add a line at the end of a file using shell scripting

Hi All ,
I am new to shell scripting.
i have a shell script(which is executed as a super user) , i want to it to do one more job for me. ie mounting a directory over other using lofs .
i have done it manually using
1) using mount command
mount -F lofs /export/home/dju /dju
2) putting an entry into the end of /etc/vstab file
/export/home/dju - /dju lofs - yes -



how can i do this in shell script .

can somebody help me.

Regards
Aki
# 2  
Old 09-19-2008
Try this.. it may help you.

Code:
echo "<Text need to add end of File >"  >>  /etc/vstab

# 3  
Old 09-19-2008
thanks 4 ur reply !!
can i be sure that line will be appended at the end of file.?Smilie
Also how can i perform mount command ...Smilie
# 4  
Old 09-19-2008
Yes it will be added at the end of the line.

For mount command :

Code:
man mount

# 5  
Old 09-19-2008
A command in a script is not different from a command you write at the command line, except you write it in a file instead, and chmod +x the file. You should probably also have an explicit #!/bin/sh at the top of the file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to add trailer record at the end of the flat file in the unix ksh shell scripting?

Hi, How to add trailer record at the end of the flat file in the unix ksh shell scripting can you please let me know the procedure Regards Srikanth (3 Replies)
Discussion started by: srikanth_sagi
3 Replies

2. Shell Programming and Scripting

Add name at the end of line in one file

Hi Folks, I want to add one name at the end of one file. Below line i have to add end of line some name... Search_masterlogin=`grep -i $masterlogin passwd.master|awk -F: '{print $1}'` $ grep -i susan passwd.master |awk -F: '{print $1}' susan $ I want to insert one name called... (10 Replies)
Discussion started by: susindram
10 Replies

3. UNIX for Dummies Questions & Answers

Add blank line to end of file

Alright, so I was looking around a bit on the forum before posting and still don't really understand so I figured I'd post my own question. I am appending two files using cat file_1.txt >> file_2.txt The problem is that I need a blank line in between the two different text files and it does... (2 Replies)
Discussion started by: cgagnon
2 Replies

4. Shell Programming and Scripting

sed/shell scripting - add line if needed and not allready there

I am writing a shell script that checks all .c files to see if they use fprintf or printf. If a file does, then the line #include <stdio.h> is added to the top of the file, unless it's already there. This is what I've got: #!/bin/sh egrep -l f?printf *.c | while read file; do sed -i '1i\... (2 Replies)
Discussion started by: computethis
2 Replies

5. Shell Programming and Scripting

add character to every end-of line in file

Hi All I have a file which conatins record.the length of every records is 47. problem : in the end of record i don't have a "\015" character. i want to add this "\015" charcter in the end of every record. the file contains something like 700 records. i've tried with sed command - nothing. ... (8 Replies)
Discussion started by: naamas03
8 Replies

6. Shell Programming and Scripting

add character to the end of each line in file

hi all i have 32 lines in file. the length of each line is 82 , i want that in the end of each line , means in postion 83-84 to put two characters 0d(=\015), 0a(=\012) i want that the 0d will be in postion 83 and the 0a will be in postion 84 in each line of the file how shall i do it ? ... (7 Replies)
Discussion started by: naamas03
7 Replies

7. Shell Programming and Scripting

Need UNIX shell scripting end to end information

Hi, I would like to learn shell scripting in UNIX. Can any one please give me the support and share the information/documents with me. If any documents please post it to aswanikumar_nimmagadda@yahoo.co.in Thanks in advance...!!! (3 Replies)
Discussion started by: aswani_n
3 Replies

8. UNIX for Dummies Questions & Answers

How to add new line character at the end of a file

hi all, i have this question: How to add new line character at the end of a file???? i need this because i am loading a file to sybase and i have problems with the last record thanks for your help (5 Replies)
Discussion started by: DebianJ
5 Replies

9. Shell Programming and Scripting

End of Line in Shell Scripting

I have a file containing records seperated by delimiter '|'.A record is contained on 2 or 3 lines. Now I need a shell script which could write all records with in two '|' character in one line.....for example..... |R1........................R1 R1..........................R1... (2 Replies)
Discussion started by: 33junaid
2 Replies

10. Shell Programming and Scripting

How to add filename to the end of each line in file

Hi, I'm reading data from comma separated files to DB. Now there is a need to have the name of the input file in each row of that file. How can I do this in unix script? Example: $cat file1 value11,value12, value,13 value21,value22, value,23 value31,value32, value,33 And the result... (2 Replies)
Discussion started by: tmikahan
2 Replies
Login or Register to Ask a Question