![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing parameters to Shell script for GREP command | sud.tech | Shell Programming and Scripting | 1 | 12-23-2008 08:32 AM |
| passing oracle parameters back to Shell | satnamx | Shell Programming and Scripting | 4 | 01-16-2007 09:59 AM |
| Passing Parameters and getting values back from a c program to Shell script | Rajeshsu | High Level Programming | 5 | 08-22-2005 04:12 AM |
| passing parameters from a shell script to sqlplus | phani | Shell Programming and Scripting | 2 | 03-13-2005 08:41 PM |
| Passing parameters in script | eliguy | UNIX for Dummies Questions & Answers | 1 | 08-01-2001 02:13 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Shell Script Passing Parameters For Directory Listing
i have this basic piece of code that i am trying to debug to accept input parameter to be able to display a directory listing of files. Code:
cd /u02/app/eatv/dev/out CURDIR=`pwd` echo directory listing of $CURDIR echo if [ $1 -e 0 ]; then ls -latr else ls -latr $1 fi basically if the script does not see any parameter being passed it will display all the file listing of the current directory. and if it find a parameter it display only a specfic files on the directory. the above code does not work and when i run i am getting this error: Code:
$ sh dir_list_eatv_out.sh *.ini directory listing of /u02/app/eatv/dev/out dir_list_eatv_out.sh[20]: -e: 0403-012 A test command parameter is not valid. ls: 0653-341 The file cca_monthly_load_data.ini does not exist. $ thanks, warren |
|
||||
|
thanks. i tried both and still getting an error. Code:
cd /u02/app/eatv/dev/out CURDIR=`pwd` echo directory listing of $CURDIR echo if [ $1 -eq 0 ]; then ls -latr else ls -latr $1 fi Code:
$ sh dir_list_eatv_out.sh *.ini directory listing of /u02/app/eatv/dev/out dir_list_eatv_out.sh[20]: cca_monthly_load_data.ini: 0403-009 The specified numb er is not valid for this command. ls: 0653-341 The file cca_monthly_load_data.ini does not exist. $ Code:
cd /u02/app/eatv/dev/out CURDIR=`pwd` echo directory listing of $CURDIR echo if [ $1 = "0" ]; then ls -latr else ls -latr $1 fi Code:
$ sh dir_list_eatv_out.sh *.ini directory listing of /u02/app/eatv/dev/out ls: 0653-341 The file cca_monthly_load_data.ini does not exist. $ |
|
||||
|
thanks. in pseudo code if input file variable is null then display the file variable listing else dislay all the files in the directory end if assuming the i pass a parameter of *.ini it will display all the files having an extension of *.ini otherwise displays all the files on the directory i tried and still there is an error Code:
#!/bin/sh
cd /u02/app/eatv/dev/out
CURDIR=`pwd`
echo directory listing of $CURDIR
echo
if [ ${1} -eq 0 ]; then
ls -latr
else
ls -latr $1
fi
Code:
$ sh sample.sh *.ini directory listing of /u02/app/eatv/dev/out sample.sh[6]: cca_monthly_load_data.ini: 0403-009 The specified number is not va lid for this command. ls: 0653-341 The file cca_monthly_load_data.ini does not exist. $ |
|
||||
|
i tried that and it did not work. Code:
$ ls -latr total 112 drwxr-sr-x 3 ccalftdv ccalogrp 512 Sep 13 2006 dev -rwxr-xr-x 1 ccalftdv ccalogrp 5586 Jun 08 15:55 cca_monthly_load_file. ksh -rwxr--r-- 1 ccalftdv ccalogrp 5729 Jun 08 15:55 load_file.ksh -rwxrwxrwx 1 ccalftdv ccalogrp 63 Jun 11 15:14 display_date.sh -rwxr-xr-x 1 ccalftdv ccalogrp 680 Jun 25 08:50 cca_monthly_load_data. ini drwxr-sr-x 4 ccalftdv ccalogrp 512 Jun 25 08:50 .. -rw-r--r-- 1 ccalftdv ccalogrp 679 Jun 25 10:28 load_data.ini -rw-r----- 1 ccalftdv ccalogrp 1281 Jun 26 10:10 dir_list_ccalloc_in.sh -rw-r----- 1 ccalftdv ccalogrp 1281 Jun 26 10:36 dir_list_ccalloc_out.s h drwxr-sr-x 3 ccalftdv ccalogrp 512 Jun 26 15:02 . -rw-r----- 1 ccalftdv ccalogrp 142 Jun 26 16:17 dir_list_eatv_out.sh $ sh dir_list_eatv_out.sh directory listing of /u02/app/eatv/dev/out total 0 drwxrwxr-x 4 oracle eatvgrp 256 Jun 19 09:41 .. drwxrwxr-x 2 oracle eatvgrp 256 Jun 24 08:00 . $ sh dir_list_eatv_out.sh *.ini directory listing of /u02/app/eatv/dev/out ls: 0653-341 The file cca_monthly_load_data.ini does not exist. $ |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|