![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Find cmd not working as expected | Vishal123 | Shell Programming and Scripting | 6 | 08-28-2007 11:11 PM |
| #/usr/bin/csh -f not working as expected? | effigy | Shell Programming and Scripting | 4 | 06-05-2006 02:00 PM |
| Var substitution in awk - not working as expected | videsh77 | Shell Programming and Scripting | 3 | 01-13-2006 10:57 AM |
| awk not working as expected with BIG files ... | videsh77 | Shell Programming and Scripting | 1 | 02-24-2005 01:15 PM |
| which not working as expected | osee | Shell Programming and Scripting | 2 | 09-07-2004 08:37 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
ls not working as expected within ksh
Hi,
I use the command ls a\b\c\*.txt from the command line on HP UNIX and it works fine - It lists all files matching *.txt in the a\b\c directory When embeded in a ksh script `ls a\b\c\*.txt` it does not work - I get *.txt not found (even though there are files) I tried variations like having escape / and such but no use. Please help. Thanks much. GNMIKE |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
For a start, your slashes are the wrong way round, but I'll assume that's a typo
Anyway, having `ls /foo/bar/*.txt` will result in a lot of "not found" errors. This is not the way to use command substitution. my_variable=`ls /foo/bar/*.txt` will work fine. In your script, just use ls /foo/bar/*.txt and it should work fine. If you're still having problems, please post your entire script. Cheers ZB |
|
#3
|
|||
|
|||
|
Hi,
Thanks for your help - Here is a part of my script... datapath would have the valye a/b/c datapatrn would have the value /*.txt (I tried /\*.txt also) batchsize would have a number such as 2 for example the result should go to a file $fileslst `ls -F1rt "$datapath" "$datafilepatrn"|head -"$batchsize">"$fileslist"` thanks again for your help |
|
#4
|
||||
|
||||
|
Quote:
Code:
use something like datapath=$source_dir/a/b/c datafilepatern='*.txt' ls -F1rt $datapath/$datafilepattern | head -"$batchsize">"$fileslist" |
|
#5
|
|||
|
|||
|
Hi,
I see your point but the problem is the same. I get *.txt not found! |
|
#6
|
||||
|
||||
|
Change
`ls -F1rt "$datapath" "$datafilepatrn"|head -"$batchsize">"$fileslist"` to ls -F1rt "$datapath$datafilepatrn"|head -"$batchsize">"$fileslist" i.e. remove the backticks, and remove the space. Can't guarantee anything without seeing the rest of your script, but if my hunch is correct - that'll fix it. Cheers ZB |
|
#7
|
|||
|
|||
|
I tried this but it still does not work...
#!/usr/bin/ksh set -x datapath=/home/oracle/APPS/mobilydw/na/source/gsm/ datafilepatrn="*.txt" fileslist=/home/oracle/APPS/mobilydw/na/bin/ ls -F1rt "$datapath""$datafilepatrn"|head -10>"$fileslist" exit |
|||
| Google The UNIX and Linux Forums |