Help with AWK Code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with AWK Code
# 1  
Old 09-10-2012
Help with AWK Code

hello,

I would appreciate a little assistance with a process I'm trying to automate. I have several files that are zipped in central location, all follow the same naming conventions i.e (file 1, file 2, etc). what i would like to do is unzip the files and combined them into one file, basically add the 2nd file to the end of the first file, and 3rd file to the end of the 2nd one and so on and so on until all the files in the folder are added. i'd like to output the data into one file. I would like to use AWK to do this but i have no idea where to start, any feedback would be greatly appreciated. thanks in advance.
# 2  
Old 09-10-2012
Why you want to use awk for this?

you can just go through all the files in a for loop or something and add them up with
cat file2 >> file 1 (or any one big file name you prefer) then move the files or delete...

u can do this in many ways actually..
# 3  
Old 09-10-2012
I was trying go get this done in AWK, just for learning purposes, since the files are zipped i was using zcat
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Deciphering AWK code

Dear experts, I am a relative novice in the Unix and came across a very useful code that I regularly use for my research blindly. I am wondering if any of the professional members could kindly briefly explain to me what the code actually does? Many thanks in advance The script is awk... (4 Replies)
Discussion started by: arsalane
4 Replies

2. Shell Programming and Scripting

Combining awk code into one

the following code works perfectly for me: # AWK 1 gawk -F, '/,'${ThisMonthDOW}' '${ThisMonthMON}' :: '${ThisMonthYEA}',/ { if (NF == 10) ... (6 Replies)
Discussion started by: SkySmart
6 Replies

3. Shell Programming and Scripting

Help fixing awk code

can someone please help me spot and fix the issue with the following code: awk -F, -v SEARCHPATT="(Wed|Tue)" -v ADDISTR="Mon|Tue|Wed|Thu|Fri|Sat|Sun" -vVF="$VALFOUND" "BEGIN{ {D = D = 1 D = D = 2 } $0 ~ "," VF "," {L = 1 ... (9 Replies)
Discussion started by: SkySmart
9 Replies

4. Shell Programming and Scripting

Optimize awk code

sample data.file: 0,mfrh_green_screen,1454687485,383934,/PROD/G/cicsmrch/sys/unikixmain.log,37M,mfrh_green_screen,28961345,0,382962--383934 0,mfrh_green_screen,1454687785,386190,/PROD/G/cicsmrch/sys/unikixmain.log,37M,mfrh_green_screen,29139568,0,383934--386190... (7 Replies)
Discussion started by: SkySmart
7 Replies

5. Shell Programming and Scripting

Need help with AWK code using xargs

Hi, I have a colon-separated file which contains names of users, among other details. My aim is to extract the line with the name and assign the name to a variable. A sample file is as follows -- ID: 123456 DEPARTMENT: xyz NAME: Bar, Foo Considering the Tabs between the colon and the... (6 Replies)
Discussion started by: Subu1987
6 Replies

6. Shell Programming and Scripting

Help in developing an awk code

#!/bin/ksh set -x FILENAME=$1 #To calculate debit and credit DEBIT=`awk -F, '{value=$28 ;if(value<0) {debit+=value}} END {print debit}' $FILENAME` CREDIT=`awk -F, '{value=$28 ;if(value>0) {credit+=value}} END {print credit}' $FILENAME` #This part is not working since the debit value is... (2 Replies)
Discussion started by: selvankj
2 Replies

7. Shell Programming and Scripting

Need help to understand Awk code.

Hi Guys, Can someone please explain this code to me. I could figure out it's adding and comparing two fields but I am not sure which ones. sort -t"|" -k3.1 /tmp/mpcashqc.xtr| awk -F"|" '{CHECKAMT+=$3;BATCHTOT=$4;\ items++}END{for(i in CHECKAMT) if (CHECKAMT!=BATCHTOT)... (6 Replies)
Discussion started by: nua7
6 Replies

8. UNIX for Dummies Questions & Answers

Shorter AWK for my code?

Hi Folks, I know my code works, but I'm still a newbie at arrays and how they function. Is there is shorter way to write my code? I'm taking averages in multiple files and concatenating output into 1 file. TIA! for file in *; do awk -F"\t" '{a1+=$1}{a2+=$2}{a3+=$3} {a4+=$4}{a5+=$5}... (1 Reply)
Discussion started by: calitiggr
1 Replies

9. Shell Programming and Scripting

Looking for awk code explaination

{ # print NF,NR,$0; if ( ($(NF-1) != 0) && ($NF != 0) ) {if ($(NF-1) > $NF) {percent=$(NF-1)/$NF-1;} else {percent=$NF/$(NF-1)-1;} } printf "%8.4f\%\n",percent*100; if (percent > 0.05||percent < -0.05 ){exit 1;} }' Use code tags please, ty. Also try to use a more... (1 Reply)
Discussion started by: bosmat shani
1 Replies
Login or Register to Ask a Question