Sponsored Content
Full Discussion: awk simple commands merge
Top Forums UNIX for Dummies Questions & Answers awk simple commands merge Post 302406126 by ruby_sgp on Monday 22nd of March 2010 05:00:06 AM
Old 03-22-2010
awk simple commands merge

Is there nice awk code for merging the following commands and do the last task?


input1

Code:
ab100    xxx    100    blahblah    +    1000
ab100    yyy    90    blahblah    +    1000
ef390    ggg    200    blahblah    -    2000
ef390    aaa    100    blahblah    -    2000
df888    ttt    300    blahhhha    -    3000
df888    bbb    300    blahhhha    -    3000

Code:
awk '{print $1,$2,$3,$4,$5,$5$6}' input1 >>input2

input2

Code:
ab100    xxx    100    blahblah    +1000
ab100    yyy    90    blahblah    +1000
ef390    ggg    200    blahblah    -2000
ef390    aaa    100    blahblah    -2000
df888    ttt    300    blahhhha    -3000
df888    bbb    300    blahhhha    -3000

Code:
awk '{print $1,$2,$3,$4,$3-$5}' input2 >>input3

input3

Code:
ab100    xxx    100    blahblah    1100
ab100    yyy    90    blahblah    1090
ef390    ggg    200    blahblah    -1800
ef390    aaa    100    blahblah    -1900
df888    ttt    300    blahhhha    -2700
df888    bbb    300    blahhhha    -2700

Code:
awk '{print $1,$2,$3,$4,abs($5)}' input3 >>input4

input4
Code:
ab100    xxx    100    blahblah    1100
ab100    yyy    90    blahblah    1090
ef390    ggg    200    blahblah    1800
ef390    aaa    100    blahblah    1900
df888    ttt    300    blahhhha    2700
df888    bbb    300    blahhhha    2700

Code:
print keys with less value in 5th column (ex: ab100 has 1090<1100)

Code:
ab100    yyy    90    blahblah    1090
ef390    ggg    200    blahblah    1800
df888    ttt    300    blahhhha    2700

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

simple commands

Can anybody help me how to display a list of unix commands. I have an account in unix,just start to use it, but don't know how (1 Reply)
Discussion started by: aningsabah
1 Replies

2. UNIX for Dummies Questions & Answers

simple Unix commands

Just hoping someone can help me out. I am looking for what should be simple commands to enter for this information: List of all Unix users (is this etc/passwd?) List of all users' access capabilities (is this etc/group?) Password settings (e.g., password expiration interval, minimum password... (2 Replies)
Discussion started by: i don't care
2 Replies

3. Shell Programming and Scripting

Simple rm commands in my server

Hi all, I have PLESK to manage my virtual dedicated server. The most recent version left a favicon.ico file in all my domains and subdomains. I want to delete them without having to go into each individual folder. So I'd like to remove favicon.ico from every subfolder of /var/www/vhosts/ ... (4 Replies)
Discussion started by: chickenhouse
4 Replies

4. Red Hat

Writing simple python setup commands

Building software in most languages is a pain. Remember ant build.xml, maven2 pom files, and multi-level makefiles? Python has a simple solution for building modules, applications, and extensions called distutils. Disutils comes as part of the Python distribution so there are no other packages... (0 Replies)
Discussion started by: Linux Bot
0 Replies

5. Shell Programming and Scripting

Merge all commands into one

how can i merge follwoing process to one... tail +5 rawdata_AAA_1.txt_$$ | grep -v "^$" >> rawdata_AAA_2.txt_$$ For discarding first 5 rows and deleting null rows awk '!/^ /{if(a) print a; a=$0}/^ /{print a}' rawdata_AAA_2.txt >> rawdata_AAA_3.txt For merging record if it split into 2 rows... (8 Replies)
Discussion started by: Amit.Sagpariya
8 Replies

6. UNIX for Dummies Questions & Answers

help with simple terminal commands

i am at home with a windows xp home, and i am using putty terminal to access my linux mathlab account, my task is to compile and run a C program, called a.c, i used gcc -Wall -g -o mycode a.c to compile it into a mycode file now when i want to run it, i was told i had to use $... (2 Replies)
Discussion started by: omega666
2 Replies

7. UNIX for Advanced & Expert Users

How to merge two commands

I have input like Unload: 2610000 225 2198 374 315 420 1149 57 2611 595 662 374 820 130 2938 486 2483 397 760 using these values, i need to divide first number with second number, means 225/2198, and using the value i'm trying to sort it. After sort i need first and "Unload" values,... (2 Replies)
Discussion started by: arivu198314
2 Replies

8. UNIX for Dummies Questions & Answers

Need help with simple Linux commands - NEWBIE here!

Hey guys, I need help with simple unix commands. I'm a newbie to Unix and don't know these commands. Any help is appreciated. 1. Logon to Linux. 2. Create a directory "Unix" under your home directory. Command(s): …………………………………………. 3. Create four... (1 Reply)
Discussion started by: loverangerguy
1 Replies

9. Homework & Coursework Questions

Need help with simple Linux commands

Hey guys, I need help with simple unix commands. I'm a newbie to Unix and don't know these commands. Any help is appreciated. 1. Logon to Linux. 2. Create a directory "Unix" under your home directory. Command(s): …………………………………………. 3. Create four... (1 Reply)
Discussion started by: loverangerguy
1 Replies

10. Shell Programming and Scripting

Merge output of 2 commands into variable

I am extracting two pieces of information from the following file: /proc/cpuinfo, that I need to merge into one report. The first command: grep -i processor /proc/cpuinfo | awk '{print $1$2,$3}' yields: processor: 0 processor: 1 processor: 2 processor: 3 The second command: grep -i... (4 Replies)
Discussion started by: jamarsh
4 Replies
All times are GMT -4. The time now is 07:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy