There may be many ways of doing this i'll describe just one & probably the easiest one.
Assuming that u r taking input from a fixed file 'input.txt' (whose content u might be changing when u have to pass different parameters). U can make a simple change in ur script. Just put this before u use the postional variables (i.e. $1,$2..etc)
A sample script can be
Above script will just print the parameters (where parameters itself come from the file). If u intend to take the filename as argument then u can do something like this: set `cat $1`
One more thing i would just like to mention is that the redirection is a capability of the shell and the script or command invoked might not even know that anything like this happened. Many commands on Unix process the standard input if no argument is specified and there u can use ur redirection but this is no way same as passing parameter. Like sort or cat, sort or display file that is passed as argument but if no argument is passed standard input is sorted(by sort) or anything written on std. input is displayed back(by cat). So in effect
sort filename (or cat filename) and sort <filename (or cat <filename) are same but they performed in very different ways. Hope u get me. An excellent description of this can be found in Programming in Unix Enviroment by Brian.W.Kerninghan & Rob Pike.
Regards
Rakesh
Last edited by Rakesh Ranjan; 04-06-2006 at 03:05 PM..
This User Gave Thanks to Rakesh Ranjan For This Post:
I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix.
I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice.
Files:... (3 Replies)
Hello,
I have been working on script in which search and replace the multiple pattern.
1. update_params.sh read the multiple pattern from input file ParamMapping.txt(old_entry|New_entry) and passing this values one by one to change_text.sh
2. change_text.sh read... (0 Replies)
In the below bash a file is downloaded when the program is opened and then that file is searched based on user input and the result is written to a new file.
For example, the bash is opened and the download.txt is downloaded, the user then enters the id (NA04520). The id is used to search... (5 Replies)
Just started learning Unix and received my first assignment recently. We haven't learned many commands and honestly, I'm stumped. I'd like to receive assistance/guidance/hints.
1. The problem statement, all variables and given/known data:
How do I write a shell script that takes in a file or... (4 Replies)
I've got a file that looks like this (spaces before first entries intentional):
12345650-000005000GL140227 ANNUAL HELC FEE EN
22345650-000005000GL140227 ANNUAL HELC FEE EN
32345650-000005000GL140227 ANNUAL HELC FEE EN
I want to read through the file line by line,... (6 Replies)
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)
Dear All ,
i stuck in one problem executing xml .. i have input xml as
<COMMAND name="ARRANGEMENT.WRITE" timestamp="0" so="initial">
<SVLOBJECT>
<LONG name="CSP_PMNT_ID" val="-1"/>
<MONEY name="CSP_CEILING" amount="0.0" currency="AUD"/>
... (6 Replies)
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)
All,
I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then
Insert file1 column2 to file2 column4 then create a new file.
File1:
12345 Sam
12346 Bob
12347 Bill
File2:... (1 Reply)
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)