Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

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

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-22-2013
Kanch Kanch is offline
Registered User
 
Join Date: Aug 2013
Last Activity: 23 August 2013, 4:04 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old Unix and Linux 08-22-2013
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 6 May 2015, 3:27 AM EDT
Location: Simplicity
Posts: 2,381
Thanks: 168
Thanked 721 Times in 650 Posts
The shell can append with >> :

Code:
for file in $7/$File_Name*
do
  echo "$Last_Record" >> "$file"
done

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed - Add a variable line to the end of a block beginning with a regex andyatit UNIX for Dummies Questions & Answers 1 04-19-2013 09:30 AM
Unable to set end of line in mail command rogerben Shell Programming and Scripting 5 08-13-2012 07:50 AM
Want to use sed to add some parameters at the end of the line asirohi Shell Programming and Scripting 5 10-23-2009 05:23 PM
Using sed command to change end of line figaro Shell Programming and Scripting 3 06-20-2009 07:18 PM
Add white space to the end of a line with sed karlanderson Shell Programming and Scripting 7 03-09-2009 06:20 AM



All times are GMT -4. The time now is 05:27 AM.