Substract and print


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Substract and print
# 1  
Old 07-19-2012
Substract and print

Dear all, I need your help. I have file input like this:

input.txt:

Code:
R1031 50111G1
R1031 50121G1
R1031 50131G1
R1031 50141G1
R1031 50151G1
.
.
.
.

Desired output:

Code:
                              10315011 = G,                              
                              10315012 = G,                              
                              10315013 = G,                              
                              10315014 = G,                              
                              10315015 = G,                              
 .
.
.
.

Thanks for advance,

Attila
# 2  
Old 07-19-2012
Code:
sed 's/[^0-9]*\([0-9]*\) \([0-9]*\)\(.\).*/\1\2 = \3,/' input.txt

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 07-19-2012
Hi


Code:
$ awk -F '[RG ]' '{print $2$3" = G,";}' file
103150111 = G,
103150121 = G,
103150131 = G,
103150141 = G,
103150151 = G,

Guru.
This User Gave Thanks to guruprasadpr For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Substract 1 Month from MonthID

Hi, I am writing a small unix command to substract one month from the MonthID. If MonthID = 201301 the below script returns me 201212 if ] then a=`echo $monthid | cut -c1-4` b=`expr $a - 1` c=12 echo "$b$c" else a=`echo $monthid | cut -c5-6` b=`expr $a - 1` c=`echo $monthid | cut... (4 Replies)
Discussion started by: pinnacle
4 Replies

2. UNIX for Dummies Questions & Answers

How to create a print filter that print text & image?

Currently, I have a print filter that takes a text file, that convert it into PCL which then gets to a HP printer. This works. Now I need to embedded a image file within the text file. I'm able to convert the image file into PCL and I can cat both files together to into a single document... (1 Reply)
Discussion started by: chedlee88-1
1 Replies

3. Shell Programming and Scripting

Need to substract date with current date and time

I have below file which contain the date in column 3,4,5 12345 open 10/10/13 10:08 PM 3 application is in java 67899 open 12/10/13 2:31 AM 2 apps can be reach 23456 open 11/9/13 2:31 AM 4 java is OK 65432 open 12/10/13 10:07 PM 9 we are... (1 Reply)
Discussion started by: vijay_rajni
1 Replies

4. Shell Programming and Scripting

How to substract selective values in multi row, multi column file (using awk or sed?)

Hi, I have a problem where I need to make this input: nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b look like this output: nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
Discussion started by: nricardo
4 Replies

5. Shell Programming and Scripting

substract variable from each line in a file

Hi everyone, I have a file containing one column and I want to subtract the first value (value of first line) from each line's value. 79304 99299 119294 139289 159284 179279 199274 219269 239264 259259 279254 299249 319244 339239 359234I tried working on an awk solution with... (1 Reply)
Discussion started by: ink_LE
1 Replies

6. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

7. Solaris

Substract time between two columns

I've start and end time in two columns. How can I substract time from column 2 and column 1 and receive output in another file 'd' ? $ cat c 12:55:04 2:03:56 2:03:56 3:20:17 14:00:00 13:05:00 (1 Reply)
Discussion started by: alps0206
1 Replies

8. Shell Programming and Scripting

substract column based on some criteria

Please guide if you know how to solve this. I have a tab delimited INPUT FILE where each record is separated by ----- ----- ABC 4935402 4936680 Pattern=Cheers07080.1 ABC 4932216 4932368 Pattern=Cheers07080.1 ABC 4931932 4932122 ... (8 Replies)
Discussion started by: sam_2921
8 Replies

9. UNIX for Dummies Questions & Answers

Substract a certain number to the names of several files

We have a list of files (raw and jpeg types) with 2 different extensions (rw2 and jpg). When there is both the raw and jpeg files, their file numbers must be the same (215 and 215, 218 and 218). Sometimes there is only the jpeg file (216,217). bla_215.rw2 bla_215.jpg bla_216.jpg bla_217.jpg... (9 Replies)
Discussion started by: Epictete
9 Replies

10. Shell Programming and Scripting

Substract date (month) Problem

#!/bin/ksh month=`date | cut -c5-8` year=`date | cut -c24-28` echo "$month" echo "$year" --- This gives me output as Feb and 2009 but now I want to substract the 1 month from the current script and want output as Jan 2009. Please note I have searched a lot on forum and found... (5 Replies)
Discussion started by: niceboykunal123
5 Replies
Login or Register to Ask a Question