Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Combine Both Output from the awk Script Post 302971712 by alvinoo on Sunday 24th of April 2016 10:46:23 PM
Old 04-24-2016
Combine Both Output from the awk Script

Hi,

Is there anyway to combine output from the awk scripting.

Code:
file01.txt:
AUE_CHMOD
AUE_CHOWN
AUE_CHROOT
AUE_CONNECT
AUE_ACCEPT
AUE_FCHOWN
AUE_FCHMOD
AUE_SETREUID
AUE_SETREGID
AUE_FCHROOT
AUE_PFEXEC
AUE_SETUID
AUE_NICE
AUE_SETGID
AUE_PRIOCNTLSYS
AUE_SETEGID
AUE_SETEUID
AUE_LCHOWN
AUE_SOCKACCEPT
AUE_SOCKCONNECT
AUE_ACLSET
AUE_FACLSET
AUE_FCHOWNAT
AUE_SETPPRIV
AUE_SETSID
AUE_SETPGID
AUE_inetd_connect
file02.txt:
AUE_CHMOD
AUE_CHOWN
AUE_CHROOT
AUE_CONNECT
AUE_ACCEPT
AUE_FCHOWN
AUE_FCHMOD
AUE_SETREUID
AUE_SETREGID
AUE_FCHROOT
AUE_PFEXEC
AUE_SETUID
AUE_NICE
AUE_SETGID
AUE_PRIOCNTLSYS
AUE_SETEGID
AUE_SETEUID
AUE_LCHOWN
AUE_SOCKACCEPT
AUE_SOCKCONNECT
AUE_ACLSET
AUE_FACLSET
AUE_FCHOWNAT
AUE_SETPPRIV
AUE_SETSID
AUE_SETPGID
AUE_inetd_connect
file03.txt:
AUE_CHMOD
AUE_CHOWN
AUE_CHROOT
AUE_CONNECT
AUE_ACCEPT
AUE_FCHOWN
AUE_FCHMOD
AUE_SETREUID
AUE_SETREGID
AUE_FCHROOT
AUE_PFEXEC
AUE_SETUID
AUE_NICE
AUE_SETGID
AUE_PRIOCNTLSYS
AUE_SETEGID
AUE_SETEUID
AUE_LCHOWN
AUE_SOCKACCEPT
AUE_SOCKCONNECT
AUE_ACLSET
AUE_FACLSET
AUE_FCHOWNAT
AUE_SETPPRIV
AUE_SETSID
AUE_SETPGID
AUE_inetd_connect

Code:
OUTPUT=4.2
END=4.3
FILELIST="file01.txt file02.txt file03.txt"

for file in $FILELIST
do
echo "$file:"
awk /"^$OUTPUT$"/,/"^$END$"/ $file | grep -v "^$OUTPUT$\|^$END$"
done

My desired output will be this if output from the awk is the same.

Code:
file01.txt,file02.txt,file03.txt:
AUE_CHMOD
AUE_CHOWN
AUE_CHROOT
AUE_CONNECT
AUE_ACCEPT
AUE_FCHOWN
AUE_FCHMOD
AUE_SETREUID
AUE_SETREGID
AUE_FCHROOT
AUE_PFEXEC
AUE_SETUID
AUE_NICE
AUE_SETGID
AUE_PRIOCNTLSYS
AUE_SETEGID
AUE_SETEUID
AUE_LCHOWN
AUE_SOCKACCEPT
AUE_SOCKCONNECT
AUE_ACLSET
AUE_FACLSET
AUE_FCHOWNAT
AUE_SETPPRIV
AUE_SETSID
AUE_SETPGID
AUE_inetd_connect

However if it is different need to split by:

Code:
file01.txt file02.txt:
[SAME CONTENT1]

file03.txt
[SAME CONTENT2]


Last edited by RudiC; 04-25-2016 at 03:48 AM.. Reason: changed quote tags to code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script the output with awk

Please i need your help. i made this script with awk, this scripts count and list a pattern for each directory in the output as shown. but not as desired. i want the output will be listed in a tabular way, using awk: cuenta_cdrs() { for dir in * do cd $dir for file in * do ... (4 Replies)
Discussion started by: alexcol
4 Replies

2. Shell Programming and Scripting

Combine Two Commands Output

How i can combine output of two commands in one file.......i tried this but it is not working although each command is working good seperately..... head -1 filename | tail -1 filename i think there is problem with command concatenator? (16 Replies)
Discussion started by: 33junaid
16 Replies

3. Shell Programming and Scripting

Combine output on same line

I am trying to get some data from a file and print it on the same line. I have a script that gets the date/time and calculates a DB query call time and sends to a file. I need to take this file and send it in a xcel like format with multiple data columns. example output file (fndbq.out) ... (3 Replies)
Discussion started by: theninja
3 Replies

4. Shell Programming and Scripting

How to combine 2 files and output the unique & difference?

Hi Guys, I have two input files and I want to combine them and get the unique values and differences and put them into one file. See below desired output file. Inputfile1: 1111111 2222222 3333333 7860068 7860069 7860071 7860072 Inputfile2: 4444444 (4 Replies)
Discussion started by: pinpe
4 Replies

5. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

6. Shell Programming and Scripting

How to combine awk and bash commands in script ?

Dear friends, I am just trying write one script using 2 files one file will contain details like below #X SERVER X LOCATION URL="http://www.abcd.com" FILENAME="abc.txt" ID_NAME="myabc_xyz" SERVER_PATH="/usr/local/dummy/html/....." #Y SERVER Y LOCATION URL="http://www.xyz.com"... (10 Replies)
Discussion started by: Akshay Hegde
10 Replies

7. UNIX for Dummies Questions & Answers

How to combine and insert missing consecutive numbers - awk or script?

Hi all, I have two (2) sets of files that are based on some snapshots of database that I want to merge and insert any missing sequential number. Below are example representation of these files: file1: DATE TIME COL1 COL2 COL3 COL4 ID 01/10/2013 0800 100 ... (3 Replies)
Discussion started by: newbie_01
3 Replies

8. Shell Programming and Scripting

Pipe or combine output of three awk commands

What is the correct syntax to pipe or run three awk commands? Basically, using the output of the first awk as input in the second. Then using the output of the second awk in the third. Thank you :). awk 'FNR==NR {E; next }$3 in E {print $3, $5}' panel_genes.txt RefSeqGene.txt > update.txt |... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. UNIX for Beginners Questions & Answers

awk Script Output Help

My code is listed below, I'm trying to figure out what the problem is and what I can do to fix it. The output i'm getting is: Name Low High Average 0 0 0.00 The correct output I want is the name of the Assignment, the lowest score and highest score obtained, and the Average Score... (10 Replies)
Discussion started by: Marquez3105
10 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
RDUP-UP(1)							       rdup								RDUP-UP(1)

NAME
rdup-up - update a directory tree with a rdup archive SYNOPSIS
rdup-up [OPTION]... DIRECTORY DESCRIPTION
With rdup-up you can update an (possibly) existing directory structure with a rdup archive. The rdup archive has to be given to rdup-up's standard input. Username and uids rdup outputs both the username and uid, the receiving system (which may be a totally different system) checks if the username and uid match. If the username and uid don't match the (numeric) uid is used on the file. The same holds true for the groupname and gid. OPTIONS
-n Do a dry-run and do not create anything on disk. -t Create DIRECTORY (ala mkdir -p) if it does not exist. -s N Strip N path components from a pathname. If the resulting pathname is empty after this operation it is skipped. Be careful however with the following structure: /foo /foo/bar /foo/bar/bla.txt /foo/blork/bla.txt With rdup-up -s2 this will leave: <empty> <empty> /bla.txt /bla.txt And the last 'bla.txt' will overwrite the previous one, this will happen without warnings. -r PATH This option is related to the -s option, but works different. The string PATH is removed from (the beginning of) each pathname. With -r /home/backup the pathname /home/backup/bin/mycmd becomes /bin/mycmd. The same could be done with -s 2, but then you need to count the slashes. Note -s is always performed before -r. -v Be more verbose and echo the processed files to standard output. -vv Be even more verbose and echo processed file and the uid and gid information to standard output. -T Show a table of contents of the rdup stream received (ala tar -tf -). With -T the directory argument is optional. -T unsets any verbose (-v) options. -h A short help message. -V Show the version. EXIT CODE
rdup-up return a zero exit code on success, otherwise 1 is returned. AUTHOR
Written by Miek Gieben. REPORTING BUGS
Report bugs to <miek@miek.nl>. SEE ALSO
http:/www.miek.nl/projects/rdup/ is the main site of rdup. Also see rdup(1), rdup-tr(1) and rdup-backups(7). COPYRIGHT
Copyright (C) 2005-2010 Miek Gieben. This is free software. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Licensed under the GPL version 3. See the file LICENSE in the source distribution of rdup. 1.1.11 13 Dec 2008 RDUP-UP(1)
All times are GMT -4. The time now is 06:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy