How to capture input files from GETOPT ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to capture input files from GETOPT ?
# 1  
Old 05-31-2007
How to capture input files from GETOPT ?

Hi...

Could somebody help me how could i captured all input files from the command line ?

As example:
#./myscript -i input -o output file1.txt file2.txt...

Then, based on the example how could i captured "file1.txt" and file2.txt ? could somebody help me ?

Attached is some of my program but i do not know how to capture that..


HTML Code:
#!/usr/bin/ksh

usage()
{
	echo "Usage: $0 -n -a -s -w -d"
	exit
}

rename()
{
	echo "test $1 $2" 
}

if [ $# -lt 1 ]; then
	usage
fi

while getopts ri:o: opt
do
	case "$opt" in
		r) rename=1;;
		i) input="$OPTARG";;
		o) output="$OPTARG";;
		\?) usage;;
	esac
done

if [ $rename ]; then
	echo "input: $input\noutput: $output - $@"
	rename $input $output
fi
# 2  
Old 05-31-2007
Not sure,

but i think they will be in $1 & $2
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 capture hostnames or ip address in the log files generated?

Team, I have prepared a script which I run from my remote machine(Jump-box)server Below is the script FILEDATE=`date +%F` LOGFILE=/home/abc/scripts/xyz.$FILEDATE.log find /home/abc/scripts/xyz.*.log -type f -mtime -3 -delete touch $LOGFILE exec 1>$LOGFILE 2>&1 #healthcheck batch runs... (1 Reply)
Discussion started by: whizkidash
1 Replies

2. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

3. Shell Programming and Scripting

Capture listed files from find command

Hi all, I am using command find $InputPath -type f -mtime +30 However, I need to capture the file listed in screen. May I know how to achieve this? Thank you. (12 Replies)
Discussion started by: ashly
12 Replies

4. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

5. Shell Programming and Scripting

Comparing files and capture return code

Hi, I would like to compare 2 files, and have a return code write to a file. regardless of the files contents are the same the code should be writing to a file (if both files contents are same then return code 0). A simple example will be great :) Thanks (3 Replies)
Discussion started by: khchong
3 Replies

6. Shell Programming and Scripting

how to capture a multi-line input

Hi Does anybody know if there is a way to capture a multi-line input and output it to the file? I was trying to use "read" for that but it only captures the first line.... I work in ksh... Any advice? Thanks a lot (5 Replies)
Discussion started by: aoussenko
5 Replies

7. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

8. Programming

How to get capture input events from keyboard and mouse

Hi, Is there any way to capture/record the input events from keyboard, as well as from mouse using C. Thanks in advance (4 Replies)
Discussion started by: yhacks
4 Replies

9. Shell Programming and Scripting

capture all the today files

My folder (e.g. /opt/successlog/) creates many files thru cron jobs everyday. I would like to retreive all the today files in this folder into a log file. How to do this for KSH? Thanks! (3 Replies)
Discussion started by: Teh Tiack Ein
3 Replies

10. UNIX for Advanced & Expert Users

Need to capture spooled print files

Hi. I run hpux 10.20. My problem is that I need to save or hold print spool files. I print using lp, and the printers are connected to HP jetdirect print servers. Any thoughts would be appreciated. Stephen Roberts (1 Reply)
Discussion started by: serware
1 Replies
Login or Register to Ask a Question