Sponsored Content
Top Forums Shell Programming and Scripting How to get fields and get output with awk or shell script.? Post 302731337 by sabercats on Wednesday 14th of November 2012 08:36:45 PM
Old 11-14-2012
Wow, it works beautiful. Thanks Chubler_XL
Now what if i have A.txt with extra 2nd field is 16
Code:
2012/11/13 20:06:11 |16|284:hawk   pid=014268 opened Locations 12, 13, 14, 15 for /home/hawk_t112/t112/macteam/qt/NET12/full_ddr3_2X_FV_4BD_1.qt/dbFiles/t112.proto|2012/11/14 15:19:26 | still running |norway|norway
2012/11/14 14:23:19 |16|  288:hawk   pid=019275 opened Locations 0, 1, 2, 3, 4, 5, 6, 7 for /home/hawk_a108/a108/macteam/qt/NET24/full_111_ddr5_soq523_2X_FV.qt/dbFiles/a108.proto|2012/11/14 15:19:26 | still running |norway|norway
2012/11/14 14:23:19 |4|  288:hawk   pid=019275 opened Locations 0, 1 for /home/hawk_a108/a108/macteam/qt/NET24/full_111_ddr5_soq523_2X_FV.qt/dbFiles/a108.proto|2012/11/14 15:19:26 | still running |germany|germany

How do we use awk or shell program to get output file B.txt
Code:
2012/11/13 20:06:11 | Locations 12, 13, 14, 15|NET12/full_ddr3_2X_FV_4BD_1.qt|norway|norway22
** 22 is first location 12+10 ** Do not include in out put

2012/11/14 14:23:19 |Locations 0, 1, 2, 3, 4, 5, 6, 7 |NET24/full_111_ddr5_soq523_2X_FV.qt|norway|norway10
** 10 is first Locations 0+10 *** Do not include in out put

2012/11/14 14:23:19 |4|  Locations 0, 1 |NET24/full_111_ddr5_soq523_2X_FV.qt|germany|germany10

and an output C.txt tell me that we are missing Locations like
Code:
Locations 8, 9, 10, 11|norway|Available
Locations 2,3|germany|Available

* If we see 2nd filed is 16 then location are 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
* If we see 2nd field is 4 then location only 0,1,2,3

Thanks for your reply.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK Merge Fields for Print Output

I've got a file with each record on a separate line and each record contains 34 fields separated by a colon and i'm trying to re-arrange the order of the fields and merge together certain fields separated by a slash (like field7/field28). I tried using an awk print statement like awk -F: 'BEGIN... (5 Replies)
Discussion started by: RacerX
5 Replies

2. Shell Programming and Scripting

awk script to (un)/concatenate fields in file

Hi everyone, I'm trying to use the "join" function for more than 1 field. Since it's not possible as it is, I want to take my input files and concatenate the joining fields as 1 field (separated by "|"). I wrote 2 awk script to do and undo it (see below). However I'm new to awk and I'm certain I... (5 Replies)
Discussion started by: anthony.cros
5 Replies

3. Shell Programming and Scripting

AWK Compare files, different fields, output

Hi All, Looking for a quick AWK script to output some differences between two files. FILE1 device1 1.1.1.1 PINGS device1 2.2.2.2 PINGS FILE2 2862 SITE1 device1-prod 1.1.1.1 icmp - 0 ... (4 Replies)
Discussion started by: stacky69
4 Replies

4. Shell Programming and Scripting

awk to compare diff output by fields

Diff output as follows: < AAA BBB CCC DDD EEE 123 > PPP QQQ RRR SSS TTT 111 > VVV WWW XXX YYY ZZZ 333 > AAA BBB CCC DDD EEE 124 How can i use awk to compare the last field to determine if the counter has increased, and need to ensure that the first 4 fields must have the same... (15 Replies)
Discussion started by: ux4me
15 Replies

5. Shell Programming and Scripting

Aligning output with null fields in shell script

Hello Gurus ! I have what probably amounts to a few simply changes to fix; however for the life of me I cannot seem to get it ti work. I need to align the output of my script (I am writing to a logfile)... here's the lines in my code: if then echo "NODE: $node" >> $logfile... (6 Replies)
Discussion started by: gvolpini
6 Replies

6. Shell Programming and Scripting

awk help: Match data fields from 2 files & output results from both into 1 file

I need to take 2 input files and create 1 output based on matches from each file. I am looking to match field #1 in both files (Userid) and create an output file that will be a combination of fields from both file1 and file2 if there are any differences in the fields 2,3,4,5,or 6. Below is an... (5 Replies)
Discussion started by: ambroze
5 Replies

7. Shell Programming and Scripting

XML Fields comparison using awk script

Hello All, I have many zipped XMLs (example file name in tgz formate - file_rec.trx.2016-01-23.000123.exc.85sesdzd45wsds5299c8f2994f7.tgz) looks following and I need to verify two numbers, they are RecordNumber and EnrolData (only sequence number, NOT hole). for all the records, both should be... (5 Replies)
Discussion started by: VasuKukkapalli
5 Replies

8. Shell Programming and Scripting

Shell script to pull certain fields

I/m a beginner so be easy. I have text files that live on an AIX server. The files come in and I've been charged with writing a shell script to email out that pulls the first date, and the last date of the file. I need to load these 2 dates into 2 separate variables. I can figure out the variables,... (13 Replies)
Discussion started by: mattadams1983
13 Replies

9. Shell Programming and Scripting

awk to output match and mismatch with count using specific fields

In the below awk I am trying output to one file those lines that match between $2,$3,$4 of file1 and file2 with the count in (). I am also trying to output those lines that are missing between $2,$3,$4 of file1 and file2 with the count of in () each. Both input files are tab-delimited, but the... (7 Replies)
Discussion started by: cmccabe
7 Replies

10. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies
CPANPLUS::Configure(3perl)				 Perl Programmers Reference Guide				CPANPLUS::Configure(3perl)

NAME
CPANPLUS::Configure - configuration for CPANPLUS SYNOPSIS
$conf = CPANPLUS::Configure->new( ); $bool = $conf->can_save; $bool = $conf->save( $where ); @opts = $conf->options( $type ); $make = $conf->get_program('make'); $verbose = $conf->set_conf( verbose => 1 ); DESCRIPTION
This module deals with all the configuration issues for CPANPLUS. Users can use objects created by this module to alter the behaviour of CPANPLUS. Please refer to the "CPANPLUS::Backend" documentation on how to obtain a "CPANPLUS::Configure" object. METHODS
$Configure = CPANPLUS::Configure->new( load_configs => BOOL ) This method returns a new object. Normal users will never need to invoke the "new" method, but instead retrieve the desired object via a method call on a "CPANPLUS::Backend" object. load_configs Controls whether or not additional user configurations are to be loaded or not. Defaults to "true". $bool = $Configure->init( [rescan => BOOL]) Initialize the configure with other config files than just the default 'CPANPLUS::Config'. Called from "new()" to load user/system configurations If the "rescan" option is provided, your disk will be examined again to see if there are new config files that could be read. Defaults to "false". Returns true on success, false on failure. can_save( [$config_location] ) Check if we can save the configuration to the specified file. If no file is provided, defaults to your personal config. Returns true if the file can be saved, false otherwise. $file = $conf->save( [$package_name] ) Saves the configuration to the package name you provided. If this package is not "CPANPLUS::Config::System", it will be saved in your ".cpanplus" directory, otherwise it will be attempted to be saved in the system wide directory. (On Debian systems, this system wide directory is /etc/perl.) If no argument is provided, it will default to your personal config. Returns the full path to the file if the config was saved, false otherwise. options( type => TYPE ) Returns a list of all valid config options given a specific type (like for example "conf" of "program") or false if the type does not exist ACCESSORS
Accessors that start with a "_" are marked private -- regular users should never need to use these. See the "CPANPLUS::Config" documentation for what items can be set and retrieved. get_SOMETHING( ITEM, [ITEM, ITEM, ... ] ); The "get_*" style accessors merely retrieves one or more desired config options. set_SOMETHING( ITEM => VAL, [ITEM => VAL, ITEM => VAL, ... ] ); The "set_*" style accessors set the current value for one or more config options and will return true upon success, false on failure. add_SOMETHING( ITEM => VAL, [ITEM => VAL, ITEM => VAL, ... ] ); The "add_*" style accessor adds a new key to a config key. Currently, the following accessors exist: set|get_conf Simple configuration directives like verbosity and favourite shell. set|get_program Location of helper programs. _set|_get_build Locations of where to put what files for CPANPLUS. _set|_get_source Locations and names of source files locally. _set|_get_mirror Locations and names of source files remotely. _set|_get_fetch Special settings pertaining to the fetching of files. BUG REPORTS
Please report bugs or other issues to <bug-cpanplus@rt.cpan.org<gt>. AUTHOR
This module by Jos Boumans <kane@cpan.org>. COPYRIGHT
The CPAN++ interface (of which this module is a part of) is copyright (c) 2001 - 2007, Jos Boumans <kane@cpan.org>. All rights reserved. This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. SEE ALSO
CPANPLUS::Backend, CPANPLUS::Configure::Setup, CPANPLUS::Config perl v5.14.2 2014-09-29 CPANPLUS::Configure(3perl)
All times are GMT -4. The time now is 06:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy