print the filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting print the filename
# 1  
Old 11-19-2008
print the filename

Code:
#!/bin/ksh

for files in `ls *.gz`
do

gunzip -c $files |  awk -v s=$files -F\" '{print s","$6}'

done

I have tried FILENAME parameter but it did not work please help.
# 2  
Old 11-19-2008
Problem solved by using nawk instead of awk.

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk to print filename words along with delimiter

Hi, I have filename as: 010020001_S-FOR-Sort-SYEXC_20180109_062320_0100.x937 I need first 5 words of my filename along with the respective delimiters: I tried this: f=010020001_S-FOR-Sort-SYEXC_20180109_062320_0100.x937 echo $f | awk -F '' '{print $1$2$3$4$5}' 010020001SFORSortSYEXC ... (11 Replies)
Discussion started by: gnnsprapa
11 Replies

2. Shell Programming and Scripting

Print filename and last line using awk

Hi, using awk command I want to print filenames and the last line of each file, in a single command line statement. I want to use 'awk', because I want to add more functionality to this logic later. I tried the following on *.sh files in the current directory find . -type f -name "*.sh"... (26 Replies)
Discussion started by: ysrini
26 Replies

3. Shell Programming and Scripting

Print filename with awk

I can got the filename with this script. it's only show "-" in result. cut -d , -f7 CSV_d.* | awk 'OFS=":"{print FILENAME,substr($1,1,8),substr($1,9,2),substr($1,11,2),substr($1,13,2)}' | sort |uniq (2 Replies)
Discussion started by: before4
2 Replies

4. UNIX for Dummies Questions & Answers

grep pipe filename print issue

uname -a SunOS mypc 5.10 Generic_141414-07 sun4v sparc SUNW,SPARC-Enterprise-T2000 uname -a SunOS mypc 5.10 Generic_144488-07 sun4v sparc SUNW,SPARC-Enterprise-T5220 find . -name "*.cer" -exec keytool -v -list -printcert -file {} \; | grep -i "Aug 03" Valid from: Mon Jan 29 00:00:00 GMT... (16 Replies)
Discussion started by: shifahim
16 Replies

5. Shell Programming and Scripting

Print only Filename based on given String on file name

Hi, I am new to this unix world. Any ways, I would like to write a shell script that can print the file name. Ex : directory will have 5 files with different name.No matter what are contents are. Now I need to find the file which will have particular name (sub string ).Please do not... (5 Replies)
Discussion started by: akb2010
5 Replies

6. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

7. Shell Programming and Scripting

Print filename inside loop

Im want to print filename inside loop .. the code im using :- Filename_1=abc_20090623_2.csv.lk Filename_2=def_20090623_2.csv.lk i want to extract filename till .csv eg Filename_1=abc_20090623_2 Filename_2=def_20090623_2 How can i do this inside the for loop ... (3 Replies)
Discussion started by: r_t_1601
3 Replies

8. AIX

split a filename and print to 2 different headings

I need help to split a filename 'a0crk_user:A0-B0123$#%test' into a0crk_user and A0-B0123 and print the output under 2 different columns namely User and Status. for eg. the output should like below: User Status ---- ------ a0crk_user A0-B0123 (3 Replies)
Discussion started by: mbak
3 Replies

9. Shell Programming and Scripting

using grep and print filename

Hi, I have a question on bash. Basically I would like to print a file name using bash. I am actually trying to grep a particular character in sequential files. I have alot files such that a.txt, b.txt,c.txt...etc. If I found a certain character, I would print that particular filename. I... (5 Replies)
Discussion started by: ahjiefreak
5 Replies

10. Shell Programming and Scripting

Print filename and resolution in wrkng dir

Greetings, I am trying to write script, (preferably in sh) that will use a proprietary program to print the resolution and name of files in the current working directory in a vertical format. I think this script will require 3 commands with variables and a pipe to the prop program, but am not... (6 Replies)
Discussion started by: rocinante
6 Replies
Login or Register to Ask a Question