Append result in the same line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Append result in the same line
# 1  
Old 06-26-2014
Append result in the same line

I have a line like below

a,blank,12,24

I want to add (12+24) at the end of the line or any where in the same line line

output:
a,blank,12,24,36
# 2  
Old 06-26-2014
Here is one way:

Code:
echo 'a,blank,12,24' | awk -F, '{print $0 "," $3+$4}'
a,blank,12,24,36

This User Gave Thanks to mjf For This Post:
# 3  
Old 06-27-2014
thanks mjf it works
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove new line starting with a numeric value and append it to the previous line

Hi, i have a file with multiple entries. After some tests with sed i managed to get the file output as follows: lsn=X-LINK-IN0,apc=661:0,state=avail,avail/links=1/1, 00,2110597,2094790,0,81,529,75649011,56435363, lsn=TM1ITP1-AM1ITP1-LS,apc=500:0,state=avail,avail/links=1/1,... (5 Replies)
Discussion started by: nms
5 Replies

2. Shell Programming and Scripting

Append Next line with current Line bassed on condition

Hi, I have an XML file and I am tring to extract some data form it, after lot of data cleaning process, I ended up with an issue, and need your urgent support. my current input data in below format: <Node>xxxxxx <Node>yyyyy</Node> <Node>zzzzzz <Node>12345</node> I need... (9 Replies)
Discussion started by: rramkrishnas
9 Replies

3. Shell Programming and Scripting

How to compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

4. UNIX for Dummies Questions & Answers

How to remove fields space and append next line to previous line.?

awk 'BEGIN{FS = "Ç"} NR == 1 {p = $0; next} NF > 1 {print p; p = $0} NF <= 1 {p = (p " " $0)} END {print p}' input.txt > output.txt This is what the input data file looks like with broken lines Code: 29863 Ç890000000 Ç543209911 ÇCHNGOHG Ç000000001 Ç055 ... (4 Replies)
Discussion started by: cumeh1624
4 Replies

5. Shell Programming and Scripting

find a certain line and append text to the end of the line

After I create printer queues in AIX, I have to append a filter file location within that printers custom file. within lets say test_queue.txt I need to find the row that starts with :699 and then I need to append on the end the string /usr/local/bin/k_portrait.sh. Now I've gotten the sed... (2 Replies)
Discussion started by: peachclift
2 Replies

6. Shell Programming and Scripting

Append next line to previous line when one pattern not found

Hi, I need help for below scenario.I have a flat file which is having records seperated by delimiters which will represent each record for oracle table.My Control file will consider each line as one record for that table. Some of the lines are aligned in two/three lines so that records are... (4 Replies)
Discussion started by: kannansr621
4 Replies

7. Shell Programming and Scripting

Append Text in Result File Name

Hi Below command is returning the list of files which having this string "MTL_SYSTEM_ITEMS". find . -name "*"|xargs grep -il MTL_SYSTEM_ITEMS Ex: Above command is returing 2 files (Out of 10 files 2 files having this string). ./file1.txt and ./file2.txt Here I want to append... (3 Replies)
Discussion started by: balajiora
3 Replies

8. Shell Programming and Scripting

Sending/append result from CSH script to xls file

Hi, 1st post... Done a quick search for this so apologies if I've missed it. Basically I want to output and and append several values generated by a csh script direct to an xls openoffice file, rather than send to txt file and then physically copy and paste to xls file. Already I send... (4 Replies)
Discussion started by: scottyjock
4 Replies

9. Shell Programming and Scripting

Joining lines in reverse. append line 1 to line 2.

Hi I have used many times the various methods to append two lines together in a file. This time I want to append the 1st line to the second and repeat for the complete file.... an example This is the file owns the big brown dog joe owns the small black dog jim What I want is ... (7 Replies)
Discussion started by: dwalley
7 Replies

10. Shell Programming and Scripting

append a string to a grep result

hello, iostat -En | grep Vendor | grep -v DV | awk '{print $1 $2}' | sort -u returns Vendor:HP I want to append Disk to it. i.e.: Disk Vendor:HP how to do that? thanks (8 Replies)
Discussion started by: melanie_pfefer
8 Replies
Login or Register to Ask a Question