![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sed and blank lines | alrinno | Shell Programming and Scripting | 6 | 07-17-2008 02:42 PM |
| How to count lines - ignoring blank lines and commented lines | kthatch | UNIX for Dummies Questions & Answers | 6 | 05-25-2007 02:21 AM |
| Eliminate blank lines... | shashi_kiran_v | UNIX for Dummies Questions & Answers | 4 | 09-06-2005 01:39 AM |
| delete blank lines or lines with spaces only | vascobrito | UNIX for Dummies Questions & Answers | 3 | 01-13-2004 07:36 AM |
| Blank Lines - End of file | saabir | Shell Programming and Scripting | 4 | 07-15-2003 12:55 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi!
I am trying to add blank lines at the end of a text file just before the last line. (This is a part of a script) For example this is my text file... lines with dashes are included Quote:
ex > echo $a > 4 So the sed command.... Code:
sed '/-----------/s/^/\n\n\n\n&/g' myfile.txt What i need is to use my variable output in a command to add the blank lines Any help will be appreciated |
|
||||
|
Thank you for the reply Franklin52
I dont know why but that didnt work for me. The output i get is exactly what i have in my text file It does not add any blank lines to it ![]() ---------- Post updated at 05:17 PM ---------- Previous update was at 05:00 PM ---------- It works fine now I just had to add awk '{ print $1 }' to your command Code:
awk -v var=$number -v n=$(wc -l < myfile.txt | awk '{ print $1 }') 'NR==n{for(i=1;i<=var;i++){print ""}}1' myfile.txt
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|