Sponsored Content
Top Forums Shell Programming and Scripting 1 command line gunzip -c get 3 output. Post 302940114 by dotran on Wednesday 1st of April 2015 12:18:07 PM
Old 04-01-2015
Thanks Vgersh9....but somehow didn't work at all.

Code:
 
 gunzip -c test.txt.gz | awk -F: '/^(Unzipped|Records|Record L)/{a[$1]+=$NF}END { for(i in a) print i FS a[i]}'
awk: a is not an array
 record number 424033

After a lot testing....I got it work. One command line gunzip -c and get 3 output (Unzipped Bytes, Records, Record, Length) same time. Thanks

Code:
 
for Dtran in $(ls `cat $New_File`)
do
LETTER=`ls | awk -F. '{print $NF}' | sort -u`
        case "$LETTER" in
        "gz" )
echo "Filename         : $Dtran" >> $README_FILE
echo " Data Format     : ASCII with carriage returns and linefeeds" >> $README_FILE
echo " Compression     : GZIP" >> $README_FILE
echo " GZIP Bytes      : `ls -l $Dtran | awk '{print $5}'`" >> $README_FILE
gunzip -c $Dtran | awk 'BEGIN { l = 0 } { l = (length)+1 } { b += (length)+1 } END { print NR" "l-1" "b }' > /tmp/gunzip_${AUTO_JOB_NAME}
echo " Unzipped Bytes  : `cat /tmp/gunzip_${AUTO_JOB_NAME} | awk '{print $3}'`" >> $README_FILE
echo " Records         : `cat /tmp/gunzip_${AUTO_JOB_NAME} | awk '{print $1}'`" >> $README_FILE
echo " Record Length   : `cat /tmp/gunzip_${AUTO_JOB_NAME} | awk '{print $2}'`" >> $README_FILE
printf '%s\n' >> $README_FILE
        ;;

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Command output on ONE line

We want to make a history of errors and append a line to a file each day. To do this we want to display the output of Date and DU (of 1 file) on ONE line. However if i type Date ; DU the output is displayed on two lines. Can Anyone help me please? The output should look like this; ... (1 Reply)
Discussion started by: Robey
1 Replies

2. Shell Programming and Scripting

reading ps command's output line by line

hi; as a pseudo; while read psLine do myFunc $psLine done < ps i don't want to redirect ps command's to a file. in fact, my problem is "how can i read stdout line by line in bash, sed, awk or any?" thanks, (5 Replies)
Discussion started by: s. murat
5 Replies

3. Shell Programming and Scripting

Bash - Loading a command's output line by line into an array

I have been trying this a lot of different ways and haven't found too much online. Here's what I've got so far: j=0 declare -a first zero=(`cat $tmpfile`) for i in "${zero}" do command $i >> "${first}" ... (4 Replies)
Discussion started by: Azrael
4 Replies

4. Shell Programming and Scripting

Can we get output on ls | wc -l command on the same line?

can we get o/p of ls | wc - l command on the same line. # ls nc*010412* | wc -l 23 # ls nc*010412* | wc -l 24 # ls nc*050412* | wc -l 21 # ls nc*040412* | wc -l 23 # ls nc*070412* | wc -l 22 my expectation is grepping specific lines from the file and... (8 Replies)
Discussion started by: sagar_1986
8 Replies

5. UNIX for Dummies Questions & Answers

command for gunzip?

Hi All This is very basic query but I have a huge folder named backup that I need to transfer. What is the command to convert the file in format backup.tar.gz so that I could transfer the folder. Is the command gzip filename? Thanks Sonia. :wall: (6 Replies)
Discussion started by: sonia102
6 Replies

6. UNIX for Dummies Questions & Answers

Gunzip and tar command

Hi I wanted to tar and gunzip a file named backup tar: backup.tar: Wrote only 2244 of 10240 bytes tar: Error is not recoverable: exiting now Please tell me what I am doing wrong? Please do help. (4 Replies)
Discussion started by: sonia102
4 Replies

7. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

8. Shell Programming and Scripting

How to execute a command on each line of output from another command?

Hello :) new to bash not to programming. I have an on-going need to change the owning group on sets of files and directories from the one they were created with or changed to on update to the one they need to have going forward. find {target_root} -group wrong_group gets me a newline... (4 Replies)
Discussion started by: naftali
4 Replies

9. Shell Programming and Scripting

How to read the output of a command line by line and pass it as a variable?

Hi, I have some 2000 names in a table like below. Java Oracle/SQL ANSI SQL SQL,DWH,DB DB&Java And by using for loop in my code i am able to get a single word but if there is any special character or space then it is considering as a next line. I have to execute the below queries in... (10 Replies)
Discussion started by: Samah
10 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 12:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy