passing multiple files as parameters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passing multiple files as parameters
# 1  
Old 11-06-2008
passing multiple files as parameters

hi all
i am etl guy

i have shell script that i use to do processing on file.
the problem is that i want it to use on multiple files at same time
is there any way of passing the file name since my all my filename start with samename like abc*

p,ease let me know
# 2  
Old 11-06-2008
you can use the for i in `ls abc*` command. Try that and post what you have if it doesn't work.
# 3  
Old 11-06-2008
yeah it work but i want to write output of each file into another file as tgt_file

like input of file1 into tgt_file1
like input of file2 into tgt_file2
# 4  
Old 11-06-2008
just to add i need to create outpiut file name on fly
# 5  
Old 11-06-2008
You can create a variable. Then add 1 to the variable and make that part of the output name.

For example

sh-3.2$ count=0
sh-3.2$ for i in `ls file*`
> do
> count=$(($count + 1))
> cat $i > "newfile${count}"
> done
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python passing multiple parameters to functions

Hi, I am a beginner in python programming. In my python script have a main function which calls several other functions. The main function gets its input by reading lines from a input text file. I call the main function for every line in input text file through a loop. def main(line): var1... (6 Replies)
Discussion started by: ctrld
6 Replies

2. Shell Programming and Scripting

Passing multiple files to awk for processing in bash script

Hi, I'm using awk command in bash script. I'm able to pass multiple files to awk for processing.The code i can use is as below(sample code) #!/bin/bash awk -F "," 'BEGIN { ... ... ... }' file1 file2 file3 In the above code i'm passing the file names manually and it is fine till my... (7 Replies)
Discussion started by: shree11
7 Replies

3. Shell Programming and Scripting

Passing 2+ parameters to one command

I have a script that uses more than one parameter. It looks like this: for i in `cat /tmp/listofpolicies`; do for x in $(cat /tmp/lst |sed 's/^/\/usr\/openv\/netbackup\/db\/class\//g'); do /usr/openv/netbackup/bin/admincmd/bpplinclude $i -delete -f $x;done;done The problem is that the... (3 Replies)
Discussion started by: newbie2010
3 Replies

4. Shell Programming and Scripting

passing parameters with spaces

we are using following script to execute stored procedue. The problem is run_pmcmd.ksh script is using $* parameter which is not taking in account 'Men Shirt' parameter which includes spaces. 1. Step 1 run_pmcmd.ksh CONVERT_TEST script for run_pmcmd.ksh /u01/$(whoami)/run_pmcmd.ksh... (11 Replies)
Discussion started by: sandy162
11 Replies

5. Shell Programming and Scripting

Passing multiple files to awk

Hi all, I have a load of files in the format e.g. a_1.out a_300.out a_20.out etc I would like to numeric sort them in ascending order by the number in the file name, then pass them into awk for manipulation. How do I do this? (8 Replies)
Discussion started by: jimjam
8 Replies

6. 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

7. Shell Programming and Scripting

Passing the parameters using a function

Hi All, I am new to shell scripting required some help in passing the parameter value to the shell script. I am writing a shell script, in the script I have created two functions as below. first function get_trend_ids () { Here I am connecting to the database and getting all the... (3 Replies)
Discussion started by: shruthidwh
3 Replies

8. Shell Programming and Scripting

Automate the passing of parameters

I am writing a script that should read the csv file and pass the values in the file as parameters to the script. The csv file looks like this: TEST_1,20110221 TEST_2,20110220 TEST_3,20110218,20110219 Currently this is how i am running the script ./test.sh <param1> <date> Ex: ./test.sh... (6 Replies)
Discussion started by: stunnerz_84
6 Replies

9. Shell Programming and Scripting

Question on passing multiple parameters in if

Hi All, My target is to find the list of orphan processes running and i issue the below command with some exception ids. ps -ef | egrep -v "root|system|admin" | awk '{if ($3 == 1) print $1",\t"$2",\t"$3}' but this will exclude the process having the word 'root' and executing under different... (1 Reply)
Discussion started by: Arunprasad
1 Replies

10. Shell Programming and Scripting

passing more than 9 parameters

hi, i am passing around 14 parameters for a script a=$1 b=$2 c=$3 d=$4 e=$5 f=$6 g=$7 h=$8 i=\"${9}\" shift j=\"${1}\" still for j it is displaying the 1st parameter value..how to make it take the 10th parameter (2 Replies)
Discussion started by: dnat
2 Replies
Login or Register to Ask a Question