Sponsored Content
Full Discussion: match and sort using awk
Top Forums Shell Programming and Scripting match and sort using awk Post 302407188 by avatar_007 on Wednesday 24th of March 2010 07:19:01 PM
Old 03-24-2010
match and sort using awk

Hello,

Is it possible to do match and sort the data from two fields in a file using awk?


Like for example:
input
applecat
inrat
outsky
catpen
ratball
skycpu
penlinux
ballunix
cpupaper
linuxphone
unix 
paper 
phone 
phone 
paper 
unix 
cpu 


desired out put
 
apple
ball ball
cat cat
cpu cpu
cpu
in
linux linux
out
paper paper
paper
pen pen
phone phone
phone
rat rat
sky sky
unix unix
unix


Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort & match multiple files

Hi, I have some question and need some guidance how to sort and match multiple files. 1. all the data in the files are numbers e.g. 1234567 1584752 2563156 2. each sorted file have their own ouput. e.g. test.csv -> test_sorted.csv 3. Then, I need to match all... (4 Replies)
Discussion started by: nazri76
4 Replies

2. Homework & Coursework Questions

awk sort help

1. The problem statement, all variables and given/known data: I dont know what I do wrong, I am trying to create shell programming database: I have this command first: && > $fname ... echo $Name:$Surname:$Agency:$Tel:$Ref: >> $fname then I have echo " Name Surname Agency Tel... (2 Replies)
Discussion started by: jeht
2 Replies

3. Shell Programming and Scripting

Sort in AWK

Hi, I usually use Access to sort data however for some reason its not working. Our systems guys and myself cannot figure it out so ive tried to use AWK to do the sorting. The file is made up of single lines in the format ... (4 Replies)
Discussion started by: eknryan
4 Replies

4. UNIX for Dummies Questions & Answers

awk display the match and 2 lines after the match is found.

Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file. For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt I tried with grep -A but it's not supported on my system. I tried with awk,... (4 Replies)
Discussion started by: eurouno
4 Replies

5. Shell Programming and Scripting

awk sort

input file abc1 abc23 abc12 abc15 output abc1 abc12 abc15 abc23 (9 Replies)
Discussion started by: yanglei_fage
9 Replies

6. UNIX for Dummies Questions & Answers

awk - (URGENT!) Print lines sort and move lines if match found

URGENT HELP IS NEEDED!! I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but - Currently, script is not printing lines to File3.txt in order. - Also the matching lines are not moving out of File1.txt ... (1 Reply)
Discussion started by: High-T
1 Replies

7. Shell Programming and Scripting

awk if match

Hi, This is the file content: #160814 20:43:00 server id 2 end_log_pos 169934694 Query thread_id=8927407 exec_time=0 error_code=0 use sun_final/*!*/; SET TIMESTAMP=1471207380/*!*/; DELETE FROM `top_pack` WHERE `top_pack`.`id` = 3023 Trying like:awk... (5 Replies)
Discussion started by: ashokvpp
5 Replies

8. Shell Programming and Scripting

awk to match field between two files and use conditions on match

I am trying to look for $2 of file1 (skipping the header) in $2 of file2 (skipping the header) and if they match and the value in $10 is > 30 and $11 is > 49, then print the line from file1 to a output file. If no match is foung the line is not printed. Both the input and output are tab-delimited.... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. Shell Programming and Scripting

awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. $1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies
PAPERCONF(1)						      General Commands Manual						      PAPERCONF(1)

NAME
paperconf - print paper configuration information SYNOPSIS
paperconf [ [ -p ] paper | -d | -a ] [ -z ] [ -n | -N ] [ -s | -w | -h ] [ -c | -m | -i ] DESCRIPTION
paperconf prints information about a given paper. The information that can be obtained is the name of the paper, its size and its width or height. When called without arguments, paperconf prints the name of the system- or user-specified paper, obtained by looking in order at the PAPERSIZE environment variable, at the contents of the file specified by the PAPERCONF environment variable, at the contents of /etc/papersize or by using letter as a fall-back value if none of the other alternatives are successful. By default, width and height of the paper are printed in PostScript points. OPTIONS
-p paper Specify the name of the paper about which information is asked. -d Use the default builtin paper name. -a Consider all known paper names. -z If the paper name is unknown, print it but issue a message on the standard error and exit with a non-zero code. -n Print the name of the paper. -N Print the name of the paper with the first letter capitalized. -s Print the size (width followed by height) of the paper. -w Print the width of the paper. -h Print the height of the paper. -c Use centimetres as unit for paper size. -m Use millimetres as unit for paper size. -i Use inches as unit for paper size. ENVIRONMENT
PAPERSIZE Paper size to use regardless of what the papersize file contains. PAPERCONF Full path to a file containing the paper size to use. FILES
/etc/papersize Contains the name of the system-wide default paper size to be used if the PAPERSIZE and PAPERCONF variables are not set. AUTHOR
Yves Arrouye <arrouye@debian.org> SEE ALSO
papersize(5) 24 April 2001 PAPERCONF(1)
All times are GMT -4. The time now is 10:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy