Sponsored Content
Full Discussion: Reducing file lines in awk
Top Forums Shell Programming and Scripting Reducing file lines in awk Post 302574937 by vasanth.vadalur on Friday 18th of November 2011 10:26:41 PM
Old 11-18-2011
Reducing file lines in awk

Hi,

Here i have to check first record $3 $4 with second record $1 $2 respectively. If match found, then check first record $2 == second record $4 , if it equals , then reduce two records to single record like as desired output.



Input_file
Code:
1 1 2 1
2 1 3 1
3 1 4 1
3 1 3 2

desired output file:
Code:
1 1 4 1 
3 1 3 2

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Help with splitting lines in a file using awk

I have a file which is one big long line of text about 10Kb long. Can someone provide a way using awk to introduce carriage returns every 40 chars in this file. Any other solutions would also be welcome. Thank you in advance. (5 Replies)
Discussion started by: martinbarretto
5 Replies

2. UNIX for Dummies Questions & Answers

Reducing file names

I have a script which includes an FTP. The filename is too long for my target area. The filename is HD012_ABCD_EFGH_061004_F_300_40. I need to the filename to be HD012_ABCD_EFGH_061004_F_. Any ideas. (5 Replies)
Discussion started by: paul1s
5 Replies

3. Solaris

reducing to root file size

My root file size has reached 80% and I am looking where all i can reduce the file size . Here is the output of top directories in / . To me none of this looks useful but not sure . We use an appplication and email. Which all can be deleted . Please advise . 2016989 989445 /var 930059 ... (2 Replies)
Discussion started by: Hitesh Shah
2 Replies

4. Shell Programming and Scripting

Select some lines from a txt file and create a new file with awk

Hi there, I have a text file with several colums separated by "|;#" I need to search the file extracting all columns starting with the value of "1" or "2" saving in a separate file just the first 7 columns of each row maching the criteria, with replacement of the saparators in the nearly created... (4 Replies)
Discussion started by: capnino
4 Replies

5. Shell Programming and Scripting

Reducing text file using similar lines

Hello, I am a java programmer but want to try unix for a purpose where I need to reduce a file using its first field.. Here is the sample data: admin;2;0;; admission;8;0;; aman;1;0;; caroline;0;4;; cook;0;4;; cook;2;0;; far;0;3;; far;1;5;; I am explaining the dataset first. There... (5 Replies)
Discussion started by: shekhar2010us
5 Replies

6. Shell Programming and Scripting

Counting lines in a file using awk

I want to count lines of a file using AWK (only) and not in the END part like this awk 'END{print FNR}' because I want to use it. Does anyone know of a way? Thanks a lot. (7 Replies)
Discussion started by: guitarist684
7 Replies

7. Shell Programming and Scripting

Reducing the decimal points of numbers (3d coordinates) in a file; how to input data to e.g. Python

I have a file full of coordinates of the form: 37.68899917602539 58.07500076293945 57.79100036621094 The numbers don't always have the same number of decimal points. I need to reduce the decimal points of all the numbers (there are 128 rows of 3 numbers) to 2. I have tried to do this... (2 Replies)
Discussion started by: crunchgargoyle
2 Replies

8. Shell Programming and Scripting

awk last n lines of file

Just my second week working on awk I need a hint for the following tasks. I want to limit my logfile from the very outset to 200 lines. All I do until now is head -c 10K >> /home/uplog.txt | awk 'END{print NR " swap " NF$5; exit}' /home/uplog.txt; After being read it shall print the very... (27 Replies)
Discussion started by: 1in10
27 Replies

9. Shell Programming and Scripting

awk remove/grab lines from file with pattern from other file

Sorry for the weird title but i have the following problem. We have several files which have between 10000 and about 500000 lines in them. From these files we want to remove lines which contain a pattern which is located in another file (around 20000 lines, all EAN codes). We also want to get... (28 Replies)
Discussion started by: SDohmen
28 Replies

10. UNIX for Beginners Questions & Answers

Reducing input file size after pattern search

I have a very large file with millions of entries identified by @M. I am using the following script to "extract" entries based on specific strings/patterns: #!/bin/bash if ] then file=$1 else echo "Input_file passed as an argument $1 is NOT found." exit; fi MID=(NULL "string-1"... (10 Replies)
Discussion started by: Xterra
10 Replies
HTTP::OAI::ListRecords(3pm)				User Contributed Perl Documentation			       HTTP::OAI::ListRecords(3pm)

NAME
HTTP::OAI::ListRecords - Provide access to an OAI ListRecords response SYNOPSIS
my $r = $h->ListRecords( metadataPrefix=>'oai_dc', ); while( my $rec = $r->next ) { print "Identifier => ", $rec->identifier, " "; } die $r->message if $r->is_error; # Using callback method sub callback { my $rec = shift; print "Identifier => ", $rec->identifier, " "; }; my $r = $h->ListRecords( metadataPrefix=>'oai_dc', onRecord=>&callback ); die $r->message if $r->is_error; METHODS
$lr = new HTTP::OAI::ListRecords This constructor method returns a new HTTP::OAI::ListRecords object. $rec = $lr->next Returns either an HTTP::OAI::Record object, or undef, if no more record are available. Use $rec->is_error to test whether there was an error getting the next record. @recl = $lr->record([$rec]) Returns the record list and optionally adds a new record or resumptionToken, $rec. Returns an array ref of HTTP::OAI::Records, including an optional resumptionToken string. $token = $lr->resumptionToken([$token]) Returns and optionally sets the HTTP::OAI::ResumptionToken. $dom = $lr->toDOM Returns a XML::DOM object representing the ListRecords response. perl v5.12.4 2011-06-23 HTTP::OAI::ListRecords(3pm)
All times are GMT -4. The time now is 08:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy