Sponsored Content
Top Forums Shell Programming and Scripting Shell Script Passing Parameters For Directory Listing Post 302330138 by wtolentino on Tuesday 30th of June 2009 10:01:23 AM
Old 06-30-2009
i got it to work by assigning the parameter to another variable.

Code:
#!/bin/sh
biff n
cd /u02/app/eatv/dev/out
CURDIR=`pwd`
pfile=$1
echo directory listing of $CURDIR
echo
if [ -z "$pfile" ]; then
  ls -latr
else
  ls -latr $pfile
fi

Code:
$ sh dir_list_eatv_out.sh
directory listing of /u02/app/eatv/dev/out

total 16
drwxrwxr-x    4 oracle   eatvgrp         256 Jun 19 09:41 ..
-rw-r--r--    1 ccalftdv ccalogrp          7 Jun 30 09:30 sample.csv
-rw-r--r--    1 ccalftdv ccalogrp          7 Jun 30 09:30 sample.txt
drwxrwxr-x    2 oracle   eatvgrp         256 Jun 30 09:31 .
$ sh dir_list_eatv_out.sh *.txt
directory listing of /u02/app/eatv/dev/out

-rw-r--r--    1 ccalftdv ccalogrp          7 Jun 30 09:30 sample.txt
$ sh dir_list_eatv_out.sh *.csv
directory listing of /u02/app/eatv/dev/out

-rw-r--r--    1 ccalftdv ccalogrp          7 Jun 30 09:30 sample.csv
$



---------- Post updated at 10:01 AM ---------- Previous update was at 09:53 AM ----------

thank you kshji that works too. on the same code you posted how do i add a parameter for the directory? yet it works if the parameter i entered is a combination of directory/file extension name. but for readability purpose we use the output as a log file to keep track of the files on the directory. we wanted to see something that on the first line of display it shows the directory name then followed by the files.

Code:
  directory listing of /u02/app/eatv/dev/out

  total 16
  drwxrwxr-x    4 oracle   eatvgrp         256 Jun 19 09:41 ..
  -rw-r--r--    1 ccalftdv ccalogrp          7 Jun 30 09:30 sample.csv
  -rw-r--r--    1 ccalftdv ccalogrp          7 Jun 30 09:30 sample.txt
  drwxrwxr-x    2 oracle   eatvgrp         256 Jun 30 09:31 .
  $

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing parameters from a shell script to sqlplus

Hi , I want to pass parameters from a shell script to a sql script and use the parameter in the sql query ..and then I want to spool a particular select query on to my unix box... for 4 different locations by writing only one sql script Right now no file is generated on the unix box...it is a... (2 Replies)
Discussion started by: phani
2 Replies

2. Programming

Passing Parameters and getting values back from a c program to Shell script

I am having a shell script which has to be called from a C program. I have to pass two parameters to this script. HOw can I do that? eg: int main() { char st1; char str2; // call a shell script call_sh(str1,str2) where call_sh is the name of the shell script. then i need to get the return... (5 Replies)
Discussion started by: Rajeshsu
5 Replies

3. Shell Programming and Scripting

passing oracle parameters back to Shell

Hi All, Does anyone have any solutions for passing back multiple variables back to the SHELL from a call to an ORACLE procedure: eg #username='scott' #password='tiger' #database='orcl' username='ITGCD03D03' password='tC5epIew' database='ITGCD03D' sqlplus -s... (4 Replies)
Discussion started by: satnamx
4 Replies

4. Shell Programming and Scripting

Passing parameters to Shell script for GREP command

I am using grep to capture date from a file . Since i need to use the shell script for different dates ,is it possible to pass the date parameter to the shell script the Script is as below grep -E "08 Aug 2008|2008-08-08"* somefile.txt>test.txt The above script file greps the... (1 Reply)
Discussion started by: sud.tech
1 Replies

5. Shell Programming and Scripting

Unix Shell Script to loop over Directory and send Filesname as parameters

Hi there I'm new to UNIX scripting; I’m stuck with the following I have an Oracle SQL script that takes three parameters 1- File Name 2- File Path 3- File creation date Under UNIX I have a folder where files will be placed frequently and I need to upload those files to Oracle, what I need... (3 Replies)
Discussion started by: windjashi
3 Replies

6. Shell Programming and Scripting

specified path name is too long passing parameters to awk via shell script

Hello, I have this shell script that runs awk code by passing in parameters however now it doesn't work anymore with the parameters and I don't know why. It removes duplicates from an input file based on a part of the last field and a key column. It removes the record with the older datetime... (0 Replies)
Discussion started by: script_op2a
0 Replies

7. Shell Programming and Scripting

Passing Variable Parameters (C shell)

I am trying to execute a copy command via shell script. However, on occassion, 2 or more files need to copied. How do I code for the multiple arguments? Does it matter how the files are delimited? Example: I have a script to copy files from 1 dir to another called duplicate.csh In most... (1 Reply)
Discussion started by: CKT_newbie88
1 Replies

8. Shell Programming and Scripting

passing parameters to the script

how can i make a script to run only when parameters are given, if parameters are not given it should through an error , saying "please enter a parameter" for ex: i want a find command to run only when the parameters are given (4 Replies)
Discussion started by: knip
4 Replies

9. Shell Programming and Scripting

Shell Script passing parameters to sqlplus code

Hello All, I am interested in finding out a way to pass parameters that are entered at the prompt from HP unix and passed to SQLPlus code with a Shell Script. Is this possible? Thanks (4 Replies)
Discussion started by: compprog11
4 Replies

10. Shell Programming and Scripting

Shell script to run sql query having a long listing of parameters

Hi, I have a query regarding execution of a sql query having long listing of parameters ..I need to execute this query inside a shell script. The scenario is like.... Suppose I have a file abc.txt that has the card numbers..it could be in thousands.. then I need to fire a query like ... (12 Replies)
Discussion started by: vsachan
12 Replies
devices(4)							   File Formats 							devices(4)

NAME
devices, devid_cache, snapshot_cache, mdi_scsi_vhci_cache, mdi_ib_cache, devname_cache - device configuration information SYNOPSIS
/etc/devices /etc/devices/devid_cache /etc/devices/snapshot_cache /etc/devices/mdi_scsi_vhci_cache /etc/devices/mdi_ib_cache /etc/devices/devname_cache DESCRIPTION
The directory /etc/devices is a repository of device-related data. Files in this directory are used to preserve this information across reboots and are created and updated as necessary by the system. There are no administrative actions necessary with respect to files in /etc/devices. Should the contents of a file become corrupted or an update fail, the file can simply be removed. The system re-creates the file as necessary. SEE ALSO
devfsadm(1M), dev(7FS), ddi_devid_compare(9F), ddi_devid_compare(9F) NOTES
Files in this directory do not constitute an API. Files might not exist or might have a different content or interpretation in a future release. The existence of this notice does not imply that any other documentation that lacks this notice constitutes an API. SunOS 5.11 8 Jun 2006 devices(4)
All times are GMT -4. The time now is 05:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy