Substitute File name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Substitute File name
# 15  
Old 03-13-2007
It seems to me that you don't actually have .Z files in your directory, as indicated by the error you got. can you show a listing of what is currently in your directory?
# 16  
Old 03-13-2007
try this

Why not put
Code:
set -vx

at the beginning of the script and see what is happening. May the the contents from the file is not being read into the variables properly.
# 17  
Old 03-13-2007
Quote:
Originally Posted by ghostdog74
It seems to me that you don't actually have .Z files in your directory, as indicated by the error you got. can you show a listing of what is currently in your directory?
Here Is the long listing :
total 4966860
-rw-r--r-- 1 oracle dba 573694919 Jan 21 2006 01.det_26dec_10jan06
-rw-r--r-- 1 oracle dba 106617087 Jan 30 2006 01a.det_11_25jan06.Z
-rw-r--r-- 1 oracle dba 115342143 Feb 14 2006 02.det_26jan_10feb06.Z
-rw-r--r-- 1 oracle dba 104965439 Feb 28 2006 02a.det_11_25feb06.Z
-rw-r--r-- 1 oracle dba 91796895 Mar 18 2006 03.det_26feb_10mar06.Z
-rw-r--r-- 1 oracle dba 136879104 Apr 4 2006 03a.det_11_31mar06.Z
-rw-r--r-- 1 oracle dba 96888889 Apr 18 2006 04.det_01_15apr06.Z
-rw-r--r-- 1 oracle dba 92467706 May 2 2006 04a.det_16_30apr06.Z
-rw-r--r-- 1 oracle dba 92596770 May 19 2006 05.det_01_15may06.Z
-rw-r--r-- 1 oracle dba 93294139 Jun 2 2006 05a.det_16_31may06.Z
-rw-r--r-- 1 oracle dba 84315109 Jun 19 2006 06.det_01_15june06.Z
-rw-r--r-- 1 oracle dba 82132177 Jul 3 2006 06a.det_16_30june06.Z
-rw-r--r-- 1 oracle dba 81434327 Jul 17 2006 07.det_01_15july06.Z
-rw-r--r-- 1 oracle dba 83665061 Aug 8 2006 07a.det_16_31july06.Z
-rw-r--r-- 1 oracle dba 74758692 Aug 19 2006 08.det_01_15aug06.Z
-rw-r--r-- 1 oracle dba 80815415 Sep 2 2006 08a.det_16_31aug06.Z
-rw-r--r-- 1 oracle dba 75974892 Sep 16 13:36 09.det_01_15sep06.Z
-rw-r--r-- 1 oracle dba 73488779 Oct 4 15:16 09a.det_16_30sep06.Z
-rw-r--r-- 1 oracle dba 69199285 Oct 17 11:42 10.det_01_15oct06.Z
-rw-r--r-- 1 oracle dba 70560621 Nov 3 09:01 10a.det_16_31oct06.Z
-rw-r--r-- 1 oracle dba 67741625 Nov 16 15:47 11.det_01_15nov06.Z
-rw-r--r-- 1 oracle dba 64394867 Dec 1 10:52 11a.det_16_30nov06.Z
-rw-r--r-- 1 oracle dba 62518866 Dec 16 12:30 12.det_01_15dec06.Z
-rw-r--r-- 1 oracle dba 64592095 Jan 1 10:15 12a.det_16_31dec06.Z
# 18  
Old 03-13-2007
Quote:
Originally Posted by ranj@chn
Why not put
Code:
set -vx

at the beginning of the script and see what is happening. May the the contents from the file is not being read into the variables properly.
Here is the output after set -vx
cat 2006cases | awk '{print $1,$2}' | while read var1 var2
cat 2006cases | awk '{print $1,$2}' | while read var1 var2
> do
do
> zcat $var2*.Z | grep "^00011$var1" >> output
zcat $var2*.Z | grep "^00011$var1" >> output
> done
done
+ cat 2006cases
+ awk {print $1,$2}
+ read var1 var2
*.Z at 01
*.Z: No such file or directory
+ grep ^0001120093878
+ read var1 var2
*.Z at 01
*.Z: No such file or directory
+ grep ^0001120901190
+ read var1 var2
*.Z at 01
*.Z: No such file or directory
+ grep ^0001120004616
+ read var1 var2
*.Z at 01
*.Z: No such file or directory
+ grep ^0001120004648
+ read var1 var2
+ grep ^0001120005124
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005157
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005163
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120010938
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120026220
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120039617
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120055789
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120074845
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120563414
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120908313
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120908355
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120908355
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120908868
*.Z at 01
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005124
*.Z at 02
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005177
*.Z at 02
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005225
*.Z at 02
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005269
*.Z at 02
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005277
*.Z at 02
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120073065
*.Z at 02
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120563414
*.Z at 02
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120567427
*.Z at 02
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005528
*.Z at 03
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005550
*.Z at 03
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005558
*.Z at 03
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120005562
*.Z at 03
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120047199
*.Z at 03
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120049280
*.Z at 03
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120069616
*.Z at 03
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120090604
*.Z at 04
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120098202
*.Z at 08
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120065833
*.Z at 10
*.Z: No such file or directory
+ read var1 var2
+ grep ^0001120900330
*.Z at 11
*.Z: No such file or directory
+ read var1 var2
# 19  
Old 03-13-2007
a little more info

Paste the top 10 lines of '2006cases' file.

Thanks.
# 20  
Old 03-13-2007
Quote:
Originally Posted by ranj@chn
Paste the top 10 lines of '2006cases' file.

Thanks.
20093878 01
20901190 01
20004616 01
20004648 01
20005124 01
20005157 01
20005163 01
20010938 01
20026220 01
20039617 01
20055789 01
20074845 01
20563414 01
20908313 01
20908355 01
20908355 01
20908868 01
20005124 02
20005177 02
20005225 02
20005269 02
20005277 02
20073065 02
20563414 02
20567427 02
20005528 03
20005550 03
20005558 03
20005562 03
# 21  
Old 03-13-2007
Slightly confused

Actually, the variables are being read properly. But instead of zcat command being executed, you get
Quote:
*.Z at 01
Check if there are any special characters in your file (Try octal dump - od -c). I am not sure if that really shows up anything.

Actually, when you set the -vx option, you get the verbose output of whats actually being substituted. It looks like the zcat is command itself is not seen anywhere in the ouput. May be you could check for aliases for zcat or it could be some other issue not related to your code. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to substitute a word in multiple file?

Team, I want to change below parameter in all the files in a directory, Check for HOSTNAME=`hostname` Change to HOSTNAME=localhost And I tried below but, its not working ☹ find /tmp -type f -exec sed 's/"HOSTNAME\=\`hostname\`"/"HOSTNAME\=localhost/g'" Help me if I am missing... (6 Replies)
Discussion started by: natraj005
6 Replies

2. UNIX for Beginners Questions & Answers

Substitute particular char in a file

I have a file like this. 1 aaa bcd 1 56 xyz 1 2 ccc rrr 1 25 512 1 1 zaz eee 1 55 511 1 I want to change middle 1's ie after bcd,rrr,eee to 0 where as other 1's should not change. Can you please provide a solution . (5 Replies)
Discussion started by: kshari8888
5 Replies

3. Shell Programming and Scripting

Substitute special Characters into a file

Hi experts :) I need to replace special characters into a file , in the followiing way : " --> "" ' --> '' _--> \_ I tried with the sed command but I'm getting and error ksh: $: not found. ksh: $: not found. sed: Function s/\/\/ cannot be parsed. Any idea ? Thanks , KOLAS... (2 Replies)
Discussion started by: Kolas79
2 Replies

4. UNIX for Dummies Questions & Answers

Help with AWK - Compare a field in a file to lookup file and substitute if only a match

I have the below 2 files: 1) Third field from file1.txt should be compared to the first field of lookup.txt. 2) If match found then third field, file1.txt should be substituted with the second field from lookup.txt. 3)Else just print the line from file1.txt. File1.txt:... (4 Replies)
Discussion started by: venalla_shine
4 Replies

5. Shell Programming and Scripting

Shell script: substitute value in text file

Hi gurus, I need help with shell script. I have various INSERT queries which inserts data into database. I want to insert 3rd column data into newline for one particular table. I have very time long txt file everytime and it have various INSERT/UPDATE queries but i have to done with it only one... (8 Replies)
Discussion started by: mirfan
8 Replies

6. Shell Programming and Scripting

How to substitute in a large gz file?

I have a large .gz file where i wish to replace the occurrence of a particular word with another word.. Can anyone help?I prefer a short script.. Can sed work with gz files? (5 Replies)
Discussion started by: maximus8886
5 Replies

7. Shell Programming and Scripting

Using awk to substitute columns from one file into another

Hi, I am new to this forum and my script skills are very weak. I have this file (file 1) that contains 3 columns (tab delimited): kyle start stop john start stop joe start stop And I want to replace name (column 1) from another file. This other file has two columns, one is the... (4 Replies)
Discussion started by: kylle345
4 Replies

8. UNIX for Dummies Questions & Answers

substitute file name

correct file names are: *_0.txt *_1.txt incorrect file names are: *_12.txt *_0123.txt *_04321.txt all files that are incorrect need to replace the ending with *_1.txt therefore need to create a loop to find the wrong files in a dir ->that dont end in _1.txt or _0.txt and then... (3 Replies)
Discussion started by: sigh2010
3 Replies

9. Shell Programming and Scripting

substitute a line in file

i have an file ,i want to substitute line 003 M 33 22 22 00 WITH NEW 003 M 24 26 28 00 how can i do it (2 Replies)
Discussion started by: RahulJoshi
2 Replies

10. Shell Programming and Scripting

how to substitute more than one word in a text file?

well i have this file here: <XML> <pregate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <system_c>HPREGATE</system_c> <trans_c>HSPG</trans_c> <trans_dt>20060105161333</trans_dt> <user_id_m></user_id_m> <func_c>C</func_c> </pregate> </XML> i want to... (2 Replies)
Discussion started by: forevercalz
2 Replies
Login or Register to Ask a Question