![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to add files to an existing tar file - HP-UNIX | Nomaad | UNIX for Dummies Questions & Answers | 5 | 3 Weeks Ago 02:27 AM |
| Replacing the last data of each line ina file | jisha | Shell Programming and Scripting | 6 | 08-04-2008 04:47 AM |
| add data from command line to end of file | bryan | UNIX for Dummies Questions & Answers | 3 | 05-23-2006 03:57 PM |
| Print one line of Existing File | danhodges99 | UNIX for Dummies Questions & Answers | 2 | 02-25-2003 08:56 AM |
| help on appending data to existing data | precious51980 | UNIX for Dummies Questions & Answers | 1 | 01-27-2001 09:56 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need to add a line of data to already existing file in Unix..
Hello..
I have a text file with 100 lines of data. I need to add 1 line of data to that already existing file at the first line( beginning of the file) , so that the already existing 100 lines will start from 2 nd line.Now the file will have 101 lines of data. Help me on how to add the line of data ?? --Charan.. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Hi,
I am a newbee as well, I think u can do it in followig ways, 1) open the file in VI and add the first line at the top 2) put the new line into another file say file2 and then do cat file2 exsistingfile > newfile newfile is your output grp please correct me if i m wrong bye Gaurav |
|
#3
|
|||
|
|||
|
Code:
echo "1i\nthis is the line that u wanted to insert \n.\nwq" | ex -s filename |
|
#4
|
||||
|
||||
|
with sed...
Code:
sed '1 i\ new first line' file > newfile && mv newfile file Code:
perl -p -i -e '$_ = "new first line\n$_" if ( $. == 1 );' file ZB |
|
#5
|
|||
|
|||
|
Madhan,
When i use echo "1i\nGROUP_NAME,JOB_NAME,STATUS,PROCESS_GROUP,JOB_START,JOB_END \n.\nwq" | ex -s abc.txt where abc.txt contains only Hello Testing Insert I am getting this.. dumb: Unknown terminal type ksh: 19464 Segmentation Fault Is that a major error..If so, How to overcome ?? |
|||
| Google The UNIX and Linux Forums |