Sponsored Content
Full Discussion: Add text to specified line
Top Forums Shell Programming and Scripting Add text to specified line Post 302656009 by birei on Thursday 14th of June 2012 06:40:16 AM
Old 06-14-2012
Hi tushar_shah06,

One way using perl (change number 3 with your line number):
Code:
$ cat infile
one
two
three
four
five
six
seven
eigth
nine
$ perl -lpe 'substr $_, length , 0, q/ ABC/ if $. == 3' infile
one
two
three ABC
four
five
six
seven
eigth
nine

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add text to file at a certain line

I am trying to add a line of text just before the last line in a file. For example, if the last line of a file is "exit 0", I need to add a line of text just before that. Any ideas how I might do that? Thanks (5 Replies)
Discussion started by: TheCrunge
5 Replies

2. Shell Programming and Scripting

how to add text after a particular line on vi editor

hi suppose i have file 0f 10 lines. i want to add something after 8 line. may i append it anyhow without opening file. eg. i can appned at last. echo text >> file Thanks (9 Replies)
Discussion started by: manoj_dahiya22
9 Replies

3. Shell Programming and Scripting

Add ; to every line in text file

Please help to add ; to every line in a text file i Have tired sed 's/$/ ; /g' > /tmp/drop_tables.sql but not working :( Thanks (2 Replies)
Discussion started by: bluebird5m
2 Replies

4. Shell Programming and Scripting

Add text at the end of line conditionally

Hi All, I have a file as below: cat myfile abcdef NA rwer tyujkl na I wish to add the text ".txt" at the end of all lines except the lines starting with NA or na. I know i can add text at the end of line using following command but I am not sure how to valiate the condition. (14 Replies)
Discussion started by: angshuman
14 Replies

5. Shell Programming and Scripting

how to add text as the new first line without getting ^M?

hi all, first post here how to add text as the new first line without getting the "^M"s in vim? I've tries echo "new_test" cat "file_to_be_edited" > new file and sed -i '1i\ new_test' file_to_be_edited these two can successfully add new_test as the new first line, but both of them... (3 Replies)
Discussion started by: sunnydanniel
3 Replies

6. Shell Programming and Scripting

how to add text into the last line of text file

I need help with insert text to the last line of text file with echo command I know can do something like echo "i4\n$logtext\n.\nwq" | ex -s $file can insert to first line, but how can i change this code in order to insert to the last line of text file? please help, thank you :( (2 Replies)
Discussion started by: gavin_L
2 Replies

7. Windows & DOS: Issues & Discussions

Trying to add text to the beginning of each line

Well here goes: I tried to write a batch file that adds a specific fixed text to each line of an already existing text file. for the adding text infront of each line I tried this: for /F "delims=" %%j in (list.txt) do echo.STARTTEXT\%%j >> list.txt for adding text after each line I... (6 Replies)
Discussion started by: pasc
6 Replies

8. Shell Programming and Scripting

sed to add text in new line

help i need to add a "nfsd" in new line after cron ex: cron rpcbind output: cron nfsd rpcbind i use sed -e "/cron/G; s/$/nfsd/" myfile output: cron nfsd rpcbindnfsd (5 Replies)
Discussion started by: jamilzain
5 Replies

9. Shell Programming and Scripting

How to add the line to previous line in | delimited text?

Hi All, I am new to Unix and I have one challenge and below are the details. I have pipe delimited text file in that data has span into multiple lines instead of single line. Sample data. Data should be like below for entire file. 41|216|398555|77|provided complete NP outcome data ... (21 Replies)
Discussion started by: Narasimhasss
21 Replies

10. Shell Programming and Scripting

Add text to the end of line

Seems simple but ive been searching for a good hour of so I have a text file and would like to add a string to the end of line 5 ( as an example) to ake tings hard the line number we have to add the text to is stored in a variable cunningly name $Line_to_append any ideas on how this could... (2 Replies)
Discussion started by: dunryc
2 Replies
GIFTI_TEST(1)							   User Commands						     GIFTI_TEST(1)

NAME
gifti_test - test reading/writing a GIFTI dataset SYNOPSIS
gifti_test [...] OPTIONS
-help Show usage help. -gifti_hist Show giftilib history. -gifti_ver Show giftilib version. -encoding TYPE Set the data encoding for any output file. TYPE = ASCII : ASCII encoding TYPE = BASE64 : base64 binary TYPE = BASE64GZIP : base64 compressed binary -gfile OUTPUT Write out dataset as gifti image. -infile INPUT Specify INPUT as the GIFTI dataset to read. -no_data Do not write out data. -show Show final gifti image. -slist LEN s0... Restrict output to list of length LEN. -verb VERB Set verbose level. EXAMPLES
1. read in a GIFTI dataset (verbose, show output?) gifti_test -infile dset.gii gifti_test -infile dset.gii -verb 3 gifti_test -infile dset.gii -show 2. copy a GIFTI dataset (check differences?) gifti_test -infile dset.gii -gfile copy.gii diff dset.gii copy.gii 3. copy a GIFTI data, but write out only 3 surf indices: 0,4,5 gifti_test -infile time_series.gii -gfile ts3.gii -slist 3 0 4 5 SEE ALSO
Website: http://www.nitrc.org/projects/gifti AUTHOR
Richard Reynolds - SSCC, DIRP, NIMH, National Institutes of Health This manual page was written by Michael Hanke <michael.hanke@gmail.com>, for the Debian project (but may be used by others). gifti_test June 2010 GIFTI_TEST(1)
All times are GMT -4. The time now is 03:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy