Sponsored Content
Top Forums Shell Programming and Scripting How to store it in a file and help with code?? Post 302493752 by Franklin52 on Thursday 3rd of February 2011 03:54:46 PM
Old 02-03-2011
Code:
awk -F\| 'NR==FNR{n=int($2); a[n]=$2; next}
a[$1]{print a[$1] FS $2}
' SAL.lis accts.fmt

Explanation:

NR==FNR if we read the first file
n=int($2) n is the part before the "-" (53031)
a[n]=$2 assign the second field to the element of array a with n as index
next read the next line of the first file
a[$1] if the first field of the second file is an index in array a
print a[$1] FS $2 print the 2nd field of the 1st file and the second field of the 1st file

Have a read of this if something is incomprehensible:

Awk - A Tutorial and Introduction - by Bruce Barnett
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Store return code of shell script in oracle table

Hi friends, I have to do the following things : 1) there should be a shell script returning the returning the return code of the script. and i have to add some more details like on which machine is has run , at what time and other details and then using plsql i have to add a row to Oracle... (3 Replies)
Discussion started by: sveera
3 Replies

2. UNIX for Dummies Questions & Answers

Need to create .bat file to store log file

Hi guys. Can someone point me to a resource that explains this? Basically these are websphere logs that need to be stored daily, I'm on sunOS 5.8. Each new file stored could have the current time as its filename. The script could be run on a cron which I can set up. I'm just not sure how to write... (0 Replies)
Discussion started by: dirtybrown
0 Replies

3. Shell Programming and Scripting

How to store Data in a File

I want to read a data from a read command and store it in a file...... Plz send me how I can do that Ex: read val and I want to store this val in a file called temp. (2 Replies)
Discussion started by: krishna_sicsr
2 Replies

4. Shell Programming and Scripting

To read and separate number and words in file and store to two new file using shell

hi, I am a begginer in unix and i want to know how to open a file and read it and separate the numbers & words and storing it in separate files, Using shell scripting. Please help me out for this. Regards S.Kamakshi (2 Replies)
Discussion started by: kamakshi s
2 Replies

5. UNIX for Dummies Questions & Answers

How to grep and store in a file

Guys, I was wondering what command can be used to parse the "LaxOrdID" field into a separate file? These messages are in thousands and I need to perform a comparision. (6 Replies)
Discussion started by: DallasT
6 Replies

6. UNIX for Dummies Questions & Answers

Writing a script that will take the first line from each file and store it in an output file

Hi, I have 1000 files names data1.txt through data1000.txt inside a folder. I want to write a script that will take each first line from the files and write them as output into a new file. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

7. Shell Programming and Scripting

Store and isolate bad pages from a file to new file

I have a file like below . The good pages must have 3 conditions : The pages that containing page total only must have 50 lines. The pages that containing customer total only must have 53 lines. The last page of Customer Total should be the last page. How can I accomplish separating good... (1 Reply)
Discussion started by: ehabaziz2001
1 Replies

8. Shell Programming and Scripting

Hit multiple URL from a text file and store result in other test file

Hi, I have a problem where i have to hit multiple URL that are stored in a text file (input.txt) and save their output in different text file (output.txt) somewhat like : cat input.txt http://192.168.21.20:8080/PPUPS/international?NUmber=917875446856... (3 Replies)
Discussion started by: mukulverma2408
3 Replies
mtu(8)							      System Manager's Manual							    mtu(8)

NAME
mtu - POLYCENTER Common Agent MIB Translator Utility SYNOPSIS
/usr/sbin/mtu [-ccode] [-i] [-l] file.mib [file.mib]... OPTIONS
Specify the EMA entity code to be assigned to the root entity. Produce an informational parameter file for input to the POLYCENTER Common Agent momgen utility (file.par). Produce a listing file containing the MIB information from the file.mib file and a summary of the mapping to EMA hierarchical structures in the file.lis file. DESCRIPTION
The mtu utility translates MIB specification files (.mib) into EMA Management Specification files (.ms). The management specifications can be loaded into the POLYCENTER Common Agent Management Information Repository (MIR) by the /usr/sbin/mirc utility. The MIB structure and syntax is described by Concise MIB Definitions (RFC-1212). The EMA Management Specification Language is described by the DECmcc System Reference Manual. If the Common Agent Developer's Toolkit layered product is installed, the mtu utility can also produce momgen information files (file.par) from the MIB specification. EXAMPLES
The following example translates the superbox.mib MIB file into the MSL file superbox.msl (named by derivation), specifying 1000 as the EMA root entity. An information parameter superbox.par is created that can be use with the momgen utility. # mtu -c 1000 -i superbox.mib The following example translates all of the MIB files in the current working directory into MSL files. For each MIB file, mtu produces the MSL file (.msl), a listing file (.lis), and a momgen informational parameter file (.par). # mtu -i -l *.mib The following example translates the tinybox.mib MIB file into the MSL file tinybox.msl, specifying 500 as the EMA root entity. A momgen informational parameter file (tinybox.par) is also generated. The smallbox.mib MIB file is translated into the MSL file smallbox.msl, specifying 1000 as the EMA root entity. A momgen informational parameter file (smallbox.par) is also generated. # mtu -c 500 -i tinybox.mib -c 1000 -i smallbox.mib FILES
A listing file that contains a numbered version of the MIB input file followed by a hierarchical management specification summary. If errors are encountered, this file contains the diagnostic at the line where the error occurred. MIB input file. MSL output file. The momgen informational parameter file. It contains class, parent, and prefix information used by the momgen utility when generating a Man- aged Object Module. SEE ALSO
Concise MIB Definition (RFC 1212) Convention for Defining Traps (RFC 1215) DECmcc System Reference Manual mtu(8)
All times are GMT -4. The time now is 07:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy