![]() |
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 |
| How to insert text in the middle of a file | kartikkumar84@g | UNIX for Dummies Questions & Answers | 6 | 05-10-2008 02:35 PM |
| insert text in the middle of a file | relle | Shell Programming and Scripting | 3 | 03-13-2008 03:37 PM |
| How to insert text into first line of the file and middle of the file? | ali hussain | Shell Programming and Scripting | 3 | 03-05-2007 05:54 AM |
| insert text into the middle of a original file | mopimp | Shell Programming and Scripting | 1 | 03-26-2006 10:11 AM |
| how to insert and delete characters in the middle of file | ivancheung | High Level Programming | 7 | 10-11-2004 03:08 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I wrote a script like
#!/bin/bash echo $1 > temp cat $2 >> temp mv temp $2 now I have problem appending the above script(only using bash shell) so that it now inserts the first argument into the middle of the file. I have tried using $(('wc -l < file' / 2 )) but invain so could any one help. Reply With Quote Last edited by boris; 04-13-2007 at 02:43 PM.. |
|
||||
|
something like this,
to be in the middle Code:
a=$((`wc -l < filename` / 2))
awk -v var=$a '{ if( NR == var) { print "newline to be added"; print } else { print } }' filename > newf
mv newf filename
|
|
||||
|
when I insert this command and run the sript it give a message stating Syntax error.....is there any other command like head or tail command
Quote:
|
|
||||
|
Quote:
Code:
sed "${a}a\\
this is new line" filename
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|