LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   append variable string in a specific line (https://www.linuxquestions.org/questions/programming-9/append-variable-string-in-a-specific-line-812859/)

himu3118 06-08-2010 06:27 AM

append variable string in a specific line
 
I want to append a variable string to the end of a specific line. not like append the same string to each line.

like in my file i have 4 columns, i want to add a string in 5th column in some fixed row.

Any help will be very welcome.

Thanks in advance..

David the H. 06-08-2010 07:30 AM

It would help if you gave a few details. Post an example of what the text looks like; i.e. the before and after states of the file. Also, how will you match the line? By line number, or by some content?

In any case, either sed or awk can do what you want quite easily.

himu3118 06-08-2010 07:44 AM

i am putting the output of time command into a file.
like
/usr/bin/time -f -o -a abc.txt "\t%E Real-time \t%S TotalCPUseconds"
and after that in the same line i want to put some file name abns.txt

like: 0:00.00 Real-time 0.00 TotalCPUseconds abns.txt

but its doing like
0:00.00 Real-time 0.00 TotalCPUseconds
abns.txt..

may be i need to remove end of line from time output??

grail 06-08-2010 08:25 AM

I am not sure I understand the issue??
You already have free text in your output, so why not just add the file name on the end:
Code:

/usr/bin/time -f -o -a abc.txt "\t%E Real-time \t%S TotalCPUseconds abns.txt"

himu3118 06-08-2010 08:49 AM

thanx


All times are GMT -5. The time now is 07:49 PM.