Sponsored Content
Top Forums Shell Programming and Scripting awk- report generation from input file Post 302175866 by yunccll on Sunday 16th of March 2008 11:25:15 AM
Old 03-16-2008
FS means Field Separator , using FS="( )|(,)" means current FS is the space or ','
if you use the statement, the result is
lastname1 111 Hilversum
lastname2 222 Bussum
lastname3 333 Amsterdam

without FS="()|(,)" result is :
lastname1 111, Hilversum
lastname2 222, Bussum
lastname3 333, Amsterdam

they are different, first is 111 and the next is 111,

Code:
> cat data
Person:
Name: Firstname1 lastname1
Address: 111, Street "Narder straat"
City : Hilversum
 
Person:
Name : Fistname2 lastname2
Address: 222, Street "Zoud straat"
City: Bussum
 
Person:
Name : Firstname2 lastname3
Address: 333, Street "Station straat"
City: Amsterdam

Code:
> awk 'BEGIN{FS="( )|(,)"} /^Name/{n=$NF}/^Address/{a=$2" "$4" "$5}/^City/{print n,a,$NF}' data
lastname1 111 "Narder straat" Hilversum
lastname2 222 "Zoud straat" Bussum
lastname3 333 "Station straat" Amsterdam

.Aaron
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Oracle Report generation

Hi, I am beginner in shell programming.In a shell script i found a call to a script 'runrep25m',which i think is to generate oracle reports?Could anyone help me by providing some details about its usage With Thanks & Regards Dileep (7 Replies)
Discussion started by: DILEEP410
7 Replies

2. UNIX for Dummies Questions & Answers

report generation

Hello, I got a requirement in writing a sheel script in unix, please help me out the requirement is there are two folders Folder1 and Folder2 and there are same files in the different folders. like file1,file2 in folder1 and file1 and file2 in folder2. I would like to compare all the... (2 Replies)
Discussion started by: gmahesh2k
2 Replies

3. Shell Programming and Scripting

Report generation

Hello, I got a requirement in writing a KSH script in unix, please help me out the requirement is there are two folders Folder1 and Folder2 and there are same files in the different folders. like file1,file2 in folder1 and file1 and file2 in folder2. I would like to compare all the similar... (3 Replies)
Discussion started by: gmahesh2k
3 Replies

4. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

5. Shell Programming and Scripting

Report Generation with Grep

All, I am pretty new to Unix Environment. I am not sure if my requirement can be accomplished in Unix. I did try searching this forum and others but could not get an answer. Requirement is explained below: I have a set of files in a folder. file1_unload file2_unload file3_unload... (7 Replies)
Discussion started by: bharath.gct
7 Replies

6. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

7. Shell Programming and Scripting

File Report Generation

hi all i need to generate a report file that contains the following details of files present in a directory. 1. File name 2.Complete path for each files and directory 3.File size 4.Days older example i have a directory testing that contains sub-directories and some files. i need to make a... (5 Replies)
Discussion started by: yashwantkumar
5 Replies

8. Shell Programming and Scripting

String generation from user input

Hi I have one thing I need advice on, and I don't know where to start so I have no sample code. I want the user to provide input like: 1-3,6,7,9-11 When the input is like this, I want a string to be generated including all the numbers. In the example above, the string would look like: 1... (13 Replies)
Discussion started by: Tobbev
13 Replies

9. Shell Programming and Scripting

Report generation using perl script

Hi, I have a perl script to read the log file and create a report from it. I have the script file and log file in a different directories. Now i have pipe the log file data to the perl script to create the report (HMTL file). I am using the below command this isn't working tail -f... (4 Replies)
Discussion started by: vel4ever
4 Replies

10. UNIX for Beginners Questions & Answers

Report generation using script

Hi all I have a unix script that generates a report with the following information: uptime, mounted file systems, disk usage (> 90% --> critical, <75%-90%> --> warning, < 75% healthy), Mem usage, CPU usage and load average. But I would like to create one single report containing all this... (5 Replies)
Discussion started by: fretagi
5 Replies
DBIx::Class::Helpers::Util(3pm) 			User Contributed Perl Documentation			   DBIx::Class::Helpers::Util(3pm)

NAME
DBIx::Class::Helpers::Util - Helper utilities for DBIx::Class components VERSION
version 2.013002 SYNOPSIS
my ($namespace, $class) = get_namespace_parts('MyApp:Schema::Person'); is $namespace, 'MyApp::Schema'; is $class, 'Person'; if (is_load_namespaces('MyApp::Schema::Result::Person')) { print 'correctly structured project'; } if (is_not_load_namespaces('MyApp::Schema::Person')) { print 'incorrectly structured project'; } if (assert_similar_namespaces('MyApp::Schema::Person', 'FooApp::Schema::People')) { print 'both projects are structured similarly'; } if (assert_similar_namespaces('MyApp::Schema::Result::Person', 'FooApp::Schema::Result::People')) { print 'both projects are structured similarly'; } DESCRIPTION
A collection of various helper utilities for DBIx::Class stuff. Probably only useful for components. METHODS
get_namespace_parts Returns the namespace and class name of a package. See "SYNOPSIS" for example. is_load_namespaces Returns true if a package is structured in a way that would work for load_namespaces. See "SYNOPSIS" for example. is_not_load_namespaces Returns true if a package is structured in a way that would not work for load_namespaces. See "SYNOPSIS" for example. assert_similar_namespaces Dies if both packages are structured in the same way. The same means both are load_namespaces or both are not. See "SYNOPSIS" for example. AUTHOR
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-18 DBIx::Class::Helpers::Util(3pm)
All times are GMT -4. The time now is 05:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy