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
apple | cat |
in | rat |
out | sky |
cat | pen |
rat | ball |
sky | cpu |
pen | linux |
ball | unix |
cpu | paper |
linux | phone |
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
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT OPENSOLARIS
paperconf
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)