Needed shell script to append desired text to each line in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Needed shell script to append desired text to each line in a file
# 1  
Old 07-28-2014
Needed shell script to append desired text to each line in a file

Hi,
I had generated a report in my tool as follows
Code:
output.txt
 43.35
 9

i needed the script to generate a new file like below
i want to append the text to each of these lines of my file
Code:
newoutputfile.txt should be
 Total Amount : 43.35
Record Count:9

Regards,
Vasa Saikumar.

---------- Post updated at 02:15 AM ---------- Previous update was at 01:55 AM ----------

hi all,
small corection in the question....

i got the file in the below format....
Code:
43.45,9

all my files wil be in the same format only like amount,count

And my new output file should be
Code:
needed outputfile.txt
 totalamount :43.45
 Count:9


Last edited by rbatte1; 07-29-2014 at 09:54 AM.. Reason: Added CODE tags
# 2  
Old 07-28-2014
Code:
awk -F, '{print "totalamount :"$1, "Count:" $2}' OFS='\n' file

# 3  
Old 07-28-2014
Or
Code:
awk -F, '{print "totalamount :" $1; print "Count:" $2}' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script UNIX to read text file line by line

i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name data_file.txt column_name file_name col1 file1 col2 file2 col3 file1 col4 file1 col5 file2 now, i would like to... (4 Replies)
Discussion started by: tester111
4 Replies

2. Shell Programming and Scripting

Need comand or script for append text after searching for the desired string

Hi all, i have a generated report in unix in the following command like input.txt 47.85,10 0124,42.35,8 0125,3.5,2 the input file format is fixed I need the my output file with append text as below output.txt 0124 amount:42.35 0125 amount:3.5 0124 count : 8 0125... (34 Replies)
Discussion started by: hemanthsaikumar
34 Replies

3. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

4. Shell Programming and Scripting

help needed with shell script to append to the end of a specific line in a file on multiple servers

Hi Folks, I was given a task to append three IP's at the end of a specific (and unique) line within a file on multiple servers. I was not able to do that with the help of a script. All I could was: for i in server1 server2 server3 server4 do ssh $i done I know 'sed' could be used to... (5 Replies)
Discussion started by: momin
5 Replies

5. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

6. Shell Programming and Scripting

get the fifth line of a text file into a shell script and trim the line to extract a WORD

FOLKS , i have a text file that is generated automatically of an another korn shell script, i want to bring in the fifth line of the text file in to my korn shell script and look for a particular word in the line . Can you all share some thoughts on this one. thanks... Venu (3 Replies)
Discussion started by: venu
3 Replies

7. Shell Programming and Scripting

How to append text to the second line of a file

Say I have a text file like: 1 3 4 How would I use ksh to put the number '2' into the second line of that file? I'm using OpenBSD so the sed syntax might be a bit different (I have no idea how to use sed, though) (4 Replies)
Discussion started by: guitarscn
4 Replies

8. Shell Programming and Scripting

How to append value at first line of CSV file using shell script?

I have an issue where I need to append a value at the last of the csv, I have created a shell script and it is appending the columns at the last but it is appending at all lines, and my requirement is specific to just append at the 1st line. Have a look and suggest, (7 Replies)
Discussion started by: anujrichhariya
7 Replies

9. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

10. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies
Login or Register to Ask a Question