How to add a line to the end of a set of files without using sed command?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to add a line to the end of a set of files without using sed command?
# 1  
Old 08-22-2013
Error How to add a line to the end of a set of files without using sed command?

I understand that the SED command reads all the lines in the file before adding a required line to the end of the file.

Is there another command that adds a line to the end of files without reading the entire file....

SED is increasing the processing time as the number of lines in each of the files is high (Say 1MB).

My current command is

Code:
sed -i '$ a\'"$Last_Record" $7/$File_Name*

Last_Record --> Line to be appended
$File_Name --> Naming pattern of the Files
$7 --> Parameter for the directory location
# 2  
Old 08-22-2013
The shell can append with >>:
Code:
for file in $7/$File_Name*
do
  echo "$Last_Record" >> "$file"
done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command to append word at end of line

hello Team, I am looking for sed command or script which will append word at end of line. for example. I want to validate particular filesystem with mount |<filesystem name> command. if nodev parameter is not there then it should add in the fstab file with receptive to the filesystem. # mount... (8 Replies)
Discussion started by: ghpradeep
8 Replies

2. UNIX for Dummies Questions & Answers

sed - Add a variable line to the end of a block beginning with a regex

Hi, Need some help with sed. I have a file that has sections : e.g. a=blah b=blah d=blah e=blah There's many sections in the file. (1 Reply)
Discussion started by: andyatit
1 Replies

3. Shell Programming and Scripting

Unable to set end of line in mail command

Hi , Am trying to send mail using the mail command, but the mail command is working but its not sending automatically after pressing .(dot) in the command prompt it sends . How to achieve that. Also it showing the below line after pressing the dot . /home/abc1/dead.letter... Saved message in... (5 Replies)
Discussion started by: rogerben
5 Replies

4. UNIX for Dummies Questions & Answers

Merge files and add file name to the end of each line

Hello everybody, I'm trying to merge a lot of files, but I want to include the filename to the end of each line. I've tried to use cat, but I got stuck. My files are for example: file01.001 123456 aaa ddd ee 458741 eee fff ee file02.003 478596 uuu ddd ee 145269 ttt fff ee ... (4 Replies)
Discussion started by: ernesto561
4 Replies

5. Shell Programming and Scripting

Want to use sed to add some parameters at the end of the line

Hello All, I have a doubt in sed, i want to add some parameter at the end of the tag inside a xml tag. how to i do that. so i want to add Results="true" value="high" inside the xml tag. Orignal <execute description="reboot"> <execute description="Stop Servlet"> After adding the... (5 Replies)
Discussion started by: asirohi
5 Replies

6. Shell Programming and Scripting

Using sed command to change end of line

I am looking to change a data file into a javascript string and this is the code that I am using: sed -i '' -e 's/^/str += "/' -e 's/$/";/' file.xml The first part -e 's/^/str += "/' works as intended, but the second part -e 's/$/";/' adds an additional newline to my file, so that instead of... (3 Replies)
Discussion started by: figaro
3 Replies

7. Shell Programming and Scripting

Add white space to the end of a line with sed

Im trying to add 5 blank spaces to the end of each line in a file in a sed script. I can figure out who o put the spaces pretty much anywhere else but at the end. thanks Karl (7 Replies)
Discussion started by: karlanderson
7 Replies

8. Shell Programming and Scripting

Command to add 1000 spaces to end of line

hi, could anyone tell me the command to append spaces at the end of the line. for example, i need 1000 spaces after the word "helloworld" echo "helloworld " i need to achieve this in someother way hardcoding 1000 spaces is not practical. as i am totally new... (3 Replies)
Discussion started by: kavithacs
3 Replies

9. UNIX for Dummies Questions & Answers

add data from command line to end of file

how can I add data from command line to end of file? (3 Replies)
Discussion started by: bryan
3 Replies
Login or Register to Ask a Question