Naming output files based on variable parameters and input filenames
Hello, I have a series of files in sub-directories that I want to loop through, process and name according to the input filename and the various parameters I'm using to process the files. I have a number of each, for example file names like AG005574, AG004788, AG003854 and parameter values like ATd, PZa, RTK1, so I want to end with files like AG005574_ATd, AG005574_PZa, AG005574_RTK1, AG004788_ATd, etc.
I loop through the subfolders, run the process and output the results like so:
Obviously, this names the file by process only, not by process_input, and it only writes one file (the last processed) because it over-writes the others. In the case above, the --out= seems to me to be the key to change to get what I want, but $output$file and variations don't work.
I'm sure this is not a tricky problem but I haven't been able to find or piece together a solution. Any help/tutoring is much appreciated.
Moderator's Comments:
select text first before clicking code button
Last edited by Scrutinizer; 01-12-2015 at 02:40 PM..
Reason: repaired code tags
output=$file is empty.
That is because it is outside the loop, try to place it 2 lines lower.
Therefor both, the current and your 'future' line:
Looks in plaintext:
Or at best (with the thought change):
For the moment, try:
Hope this helps
in the <options> for the process I run, I point to several different models for processing, like so:
so that when I have
--out=$model."tab" I get part of the filename I want for my output (namely, the model I used) but not the name of the input file that was processed, and each new file that is processed over-writes the previous.
when I try something like
or
or
the process/program errors. The solution you suggested also causes an error message from the program, "no such option --tblfp", which makes no sense to me.
I have a below syntax its working fine...
var12=$(ps -ef | grep apache | awk '{print $2,$4}')
Im getting expected output as below:
printf "%b\n" "${VAR12}"
dell 123
dell 456
dell 457
Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Using Linux (bash), I have two files which contain information about berries. Example:
file1.txt:
Blueberry blue 14
Raspberry red 12
Blackberry dark 4
file2.txt
Blackberry sour 4 3
Blueberry tasty 12 78
Strawberry yummy 33 88
I want to merge these two files into one. The desired... (5 Replies)
Hi All,
I have a UNIX script which reads "PxyType" (read PxyType) as input from user and a file (eg : "File.json") with the list all PxyType's.
Based on the user input for "PxyType" in "File.json", I want to redirect each matched line to a different file ("File1,2,3,..json").
Can you... (7 Replies)
Hi,
I have many test*.ft1 files to which I want to read as input for a script called
pipe2txt.tcl and print the output in each separate file.
For example,
pipe2txt.tcl < test001.ft1 > test001.txt
How can I read many files in this maner?
thank you very much,
Best,
Pahuja (5 Replies)
for every specific $1,$2 check the values ($2,$3) of their E ot I of input1 and overlap with input2.
Specify names based on output.
#######
if middle value is missing name them "SE"
if first value is missing name them "AFE"
if last value is missing name them "ALE"
if 2 middle values are... (1 Reply)
Hi
I would like to use tar cmd in my script.
I have a variable with filenames, e.g. 1000 records and I would like to paste its values into tar cmd.
For this example I used three elements variable strings.
strings="file1.txt file2.txt file3.txt"
`tar cf file1.tar $strings`
Whether... (1 Reply)
I was just thinking if there is a way where i can dynamically rename files based on the actual file content.
I have a load of pdf's which have been named wrongly. (We normally put date first, then brief description, then title)
So can a script be written wherin, it pulls out the date and title... (2 Replies)
I would like ot create shell script/ bash to create diffrent files based on a file and parameters list.
Here is the detail example: I have a textfile and four static parameter files (having ‘?'). mainfile.txt has below records (this count may be more than 50)
A200001
A200101
B200001... (9 Replies)
I have a file given below. I want to split the file where ever I came across
***(instead you can put ### symbols in the file) . Also I need to name the file by extracting the report name from the first line which is in bold(eg:RPT507A) concatinated with DD(day on which the file runs). Can someone... (1 Reply)