Sponsored Content
Top Forums UNIX for Advanced & Expert Users Help using awk with a text file Post 302788685 by ziggy6 on Tuesday 2nd of April 2013 10:45:53 AM
Old 04-02-2013
Using Awk with text file

This is a major step in the right direction, but the output file names still have not been specified. Do you really want leading spaces on the output file names when customer numbers are less than five digits? It is easy to put them in (as requested), but it will make handling these files harder for you. Would you prefer to have leading zeroes added so the filename always starts with a 5 digit customer number? I would not use leading spaces for the account #, I can either have it with leading zero's or without, I prefer without leading zero's.

Where do the last 4 digits of the output file names come from? They don't come from the dates on lines 8, 18, or 19 in your 55 line statements. Are they always supposed to be 0313? Are they supposed to be the two digit month and two digit year corresponding to the date when the script is run? The last 4 digits will come from the system time and date which will always be run on the last day of the month so I would use month and year. I usually use the following to come up with my date,
date '+ %c/%m/%d' > date hold
y=`cat date.hold | cut -c24-25`
m=`cat date.hold | cut -c27 -c28`
then I would use variables $y and $m in naming the file

Are the multiple occurrences of the strings "^L" and "^M" in you input file literal characters that you want kept in the output files? Are they a graphic representation of form feed and carriage return characters that you want kept in the output files? Or, are they a graphic representation of form feed and carriage return characters that you want to be stripped from the output? As you noted they are carriage return and form feed and I would want them in the output file as well

If there are multiple statements for a given customer number, are they always adjacent records in the input file? Yes, if a statement is more than 1 page it would be adjacent to the first statement so if account 9 had multiple pages one would follow after the other.

What shell do you want to use and what operating system are you using? SCO 5.0.7 and using the bourne shell
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

process text file with awk

I have a text file which represent a http packet: header1 haeder2 ..... ..... headern payload I need to count bytes in the payload. How can I get it using awk? Thanks in advance Andrea Musella (2 Replies)
Discussion started by: littleboyblu
2 Replies

2. Shell Programming and Scripting

awk to reformat a text file

I am definitely not an expert with awk, and I want to reformat a text file like the following. This is probably a very easy one for an expert out there. I would like to keep the lines in the same order, but move the heading to only be listed once above the lines. This is what the text file... (7 Replies)
Discussion started by: linux4life
7 Replies

3. Shell Programming and Scripting

search text file in file if this file contains necessary text (awk,grep)

Hello friends! Help me pls to write correct awk and grep statements for my task: I have got files with name filename.txt It has such structure: Start of file FROM: address@domen.com (12...890) abc DATE: 11/23/2009 on Std SUBJECT: any subject End of file So, I must check, if this file... (4 Replies)
Discussion started by: candyme
4 Replies

4. UNIX for Advanced & Expert Users

Help using Awk and cut with a text file

Looking for some help on using awk and cut I have a text file that has fixed information and want to write a script that will prompt the user for an account to search for and pint the output The sample line that has the key information looks like this: Statement to: ... (5 Replies)
Discussion started by: ziggy6
5 Replies

5. Shell Programming and Scripting

Awk to convert a text file to CSV file with some string manipulation

Hi , I have a simple text file with contents as below: 12345678900 971,76 4234560890 22345678900 5971,72 5234560990 32345678900 71,12 6234560190 the new csv-file should be like: Column1;Column2;Column3;Column4;Column5 123456;78900;971,76;423456;0890... (9 Replies)
Discussion started by: FreddyDaKing
9 Replies

6. Shell Programming and Scripting

Search and replace from file in awk using a 16 bit text file

Hello, Some time ago a helpful awk file was provided on the forum which I give below: NR==FNR{A=$0;next}{for(j in A){split(A,P,"=");for(i=1;i<=NF;i++){if($i==P){$i=P}}}}1 While it works beautifully on English and Latin characters i.e. within the ASCII range of 127, the moment a character beyond... (6 Replies)
Discussion started by: gimley
6 Replies

7. Shell Programming and Scripting

awk to reformat text file

Howdy. AWK beginner here. I need to reformat a text file in the following format: TTGS08-2014001 6018.00 143563.00 ... (2 Replies)
Discussion started by: c47v3770
2 Replies

8. Shell Programming and Scripting

Splitting a text file into smaller files with awk, how to create a different name for each new file

Hello, I have some large text files that look like, putrescine Mrv1583 01041713302D 6 5 0 0 0 0 999 V2000 2.0928 -0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 5.6650 0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 3.5217 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

9. UNIX for Beginners Questions & Answers

awk to update file with partial matching line in another file and append text

In the awk below I am trying to cp and paste each matching line in f2 to $3 in f1 if $2 of f1 is in the line in f2 somewhere. There will always be a match (usually more then 1) and my actual data is much larger (several hundreds of lines) in both f1 and f2. When the line in f2 is pasted to $3 in... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
lsdev(1M)																 lsdev(1M)

NAME
lsdev - list device drivers in the system SYNOPSIS
driver | class] block_major] char_major] major] [major ...] DESCRIPTION
The command lists, one pair per line, the major device numbers and driver names of device drivers configured into the system and available for invocation via special files. A in either the block or character column means that a major number does not exist for that type. If no arguments are specified, lists all drivers configured into the system. If the option is specified, will not print a heading. This option may be useful when the output of will be used by another program. The and options are used to select specific device drivers for output. If more than one option is specified, all drivers that match the criteria specified by those options will be listed. These search options are divided into two types: name search keys (the and options) and major number search keys (the and options). If both types of options are present, only entries that match both types are printed. The same type of option may appear more than once on the command line with each occurrence providing an ORing effect of that search type. The and options may not be specified at the same time. The ability to process major arguments is provided for compatibility and functions like the option. Options List device drivers that match class. List device drivers with the name driver. List device drivers with a block major number of block_major. List device drivers with a character major number of char_major. List device drivers with either a character major number or block major equal to major. DIAGNOSTICS
The and options may not be specified at the same time. A major number is malformed or out of range. EXAMPLES
To output entries for all drivers in the class: To output entries that are in the class that have either a block or character major number of To get the character major number of into a shell environment variable: WARNINGS
Some device drivers available from the system may be intended for use by other drivers. Attempting to use them directly from a special file may produce unexpected results. A driver may be listed even when the hardware requiring the driver is not present. Attempts to access a driver without the corresponding hardware will fail. only lists drivers that are configured into the currently executing kernel. For a complete list of available drivers, please run (see sam(1M). DEPENDENCIES
Since relies on the device driver information provided in a routine, may not list drivers installed by other means. AUTHOR
was developed by HP. SEE ALSO
sam(1M). Section 7 entries related to specific device drivers. lsdev(1M)
All times are GMT -4. The time now is 08:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy