awk script for modifying the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk script for modifying the file
# 1  
Old 09-28-2011
awk script for modifying the file

I have the records in the format
one row
Code:
0009714494919I  MY010727408948010   NNNNNN N PUSAAR727408948010   R007YM08705 9602002     S   111+0360832-0937348

I want to get it int the format
Code:
0009714494919I  MY010727408948010   NNNNNN N PUSAAR727408948010   R007YM08705 9602002     S   111+036.0832-093.7348

how to do it using awk?

Moderator's Comments:
Mod Comment Use code tags, see PM, thanks.

Last edited by zaxxon; 09-28-2011 at 04:53 AM.. Reason: code tags
# 2  
Old 09-28-2011
Code:
 
$ nawk -F\+ '{a=substr($2,1,3)"."substr($2,4,index($2,"-"))"."substr($2,length($2)-3,length($2)); printf("%s+%s\n",$1,a)}' inputfile

# 3  
Old 09-28-2011
thanks...its working .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Modifying an awk script for syllable splitting

I have found this syllable splitter in awk. The code is given below. Basically the script cuts words and names into syllables. However it fails when the word contains 2 consonants which constitute a single syllable. An example is given below ashford raphael The output is as under: ... (4 Replies)
Discussion started by: gimley
4 Replies

2. Shell Programming and Scripting

Modifying bash script to take each line in a file and execute command

I need to modify a bash script to to take each line in a file and execute command. I currently have this: #!/bin/bash if ; then echo "Lipsa IP"; exit; fi i=1 ip=$1 while ; do if ; then rand=`head -$i pass_file | tail -1` user=`echo $rand | awk '{print $1}'` pass=`echo $rand | awk '{print $2}'`... (3 Replies)
Discussion started by: galford
3 Replies

3. Shell Programming and Scripting

Awk: Modifying columns based on comparison

Hi, I have following input in the file in which i want to club the entries based on $1. Also $11 is equal to $13 of other record(where $13 must be on higher side for any $1) then sum all other fields except $11 & $13. Final output required is as follows: INPUTFILE: ... (11 Replies)
Discussion started by: siramitsharma
11 Replies

4. Shell Programming and Scripting

Modifying contents of the file in shell script

Hello all, I have a Kconfig file that looks like something below ... ================================ menu "Application type" config GUI_TYPE_STANDARD bool "Standard Application" source "cfg/config/std.in" source... (12 Replies)
Discussion started by: anand.shah
12 Replies

5. Shell Programming and Scripting

Modifying awk code to be inside condition

I have the following awk script and I want to change it to be inside a condition for the file extension. ################################################################################ # abs: Returns the absolute value of a number function abs(val) { return val > 0 ? val \ ... (4 Replies)
Discussion started by: kristinu
4 Replies

6. UNIX for Dummies Questions & Answers

Understanding / Modifying AWK command

Hey all, So I have an AWK command here awk '{if(FNR==NR) {arr++;next} if($0 in arr) { arr--; if (arr == 0) delete arr;next}{print $0 >"list2output.csv"}} END {for(i in arr){print i >"list1output.csv"}}' list1 list2 (refer to image for a more readable format) This code was submitted... (1 Reply)
Discussion started by: Aussiemick
1 Replies

7. Shell Programming and Scripting

AWK script for programatically modifying java files

Hi, I want to add a String variable to all java classes in my project. Assuming a class like public class Random { String var="Constant string"; ... ... ... } The text in bold is what I want to add to all java files in my workspace. I am an absolute newbie to AWK, and read somewhere that... (5 Replies)
Discussion started by: rocker86
5 Replies

8. Shell Programming and Scripting

modifying a awk line

Hi, I want to print specific columns (from 201 to 1001). The line that I am using is listed below. However I also want to print column 1. So column 1 and 201 to 1001. What modifcations do I need to make? Code: awk -F'\t' 'BEGIN {min = 201; max = 1001 }{for (i=min; i<=max; i++) printf... (5 Replies)
Discussion started by: phil_heath
5 Replies

9. Shell Programming and Scripting

modifying file using script

Hi, I am new to shell programming, and want to know is it possible to change the contents of file using script? for example, if want to search 2 words and want to replace these words with 2 new words. Regards, Manoj (4 Replies)
Discussion started by: manoj.solaris
4 Replies

10. Shell Programming and Scripting

Modifying a csv file from Shell Script

Hi all, I have some script that creates a temp csv file. What I need to do is do some search and replace and modify the file from my shell script. I know the commands to open the file and then apply the reg ex but wasnt sure how I could do this from a script and modify the file? Any help... (2 Replies)
Discussion started by: not4google
2 Replies
Login or Register to Ask a Question