The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
Reading specific contents from 1 input files and appending it to another input file sksahu Shell Programming and Scripting 5 01-14-2009 06:09 AM
passing an input parameter like date thru jcl using BPXBATCH utility Sujatha Gowda SUN Solaris 0 06-03-2008 08:23 AM
awk/input parameter wannalearn Shell Programming and Scripting 3 07-30-2007 01:42 PM
Input parameter format mpang_ Shell Programming and Scripting 1 04-12-2006 04:34 AM
Shell script with input parameter jhmr7 UNIX for Dummies Questions & Answers 1 07-13-2005 12:04 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-30-2009
wtolentino wtolentino is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 33
How to Get the File Input from Parameter

Code:
pdir=`pwd`
if [ $# -lt 1 ]; then
 echo current directory $pdir
 ls -altr
 echo
fi
for f in $*
do
    # directory
    if [ -d $f ]; then
      echo current directory $f
      cd $f
      ls -latr
      echo
    fi

    # but you can test file/dir
    # regular file only
    if [ -f $f ]; then
      echo current directory $pdir
      ls -altr $f
      echo
    fi

done
i have a basic code on shell script that accepts parameter for directory name with or without a filename or extension file name.

if i enter this below on the command line
Code:
sh dir_file_list.sh /u02/app/eatv/dev/out/*.txt
it give me this output:
Code:
current directory /export/home/ccalftdv/apps
-rw-r--r--    1 ccalftdv ccalogrp          7 Jun 30 09:30 /u02/app/eatv/dev/out/
sample.txt

$
how do i capture the string *.txt or the filename on the input parameter? thanks.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0