I am trying to read 30 files into a command. The first file contains 10 lines and goes into this part of the command as "x"
/tmp/filearrange.sh $x
The group of files (20 files, I call them variable $i) need to be the second argument in the command and they need to be read so that they are paired with the other command.
So each line is read one at a time, example
So
looks like this (example)
What I have tried so far is to use paste but it takes only 12 lines. Then I tried filedescriptors, but it appears I would need to use as input a variable to the file descriptor like this:
and I can't get this working.
I'm really confused about this in bash. Any help is appreciated.
Last edited by Scrutinizer; 07-21-2013 at 06:14 PM..
If invfile contains:
and your "group of files" is files named g1, g2, and g3, what arguments do you want to pass to your bash script and exactly how many times should that script invoke /tmp/filearrange.sh?
And for each of those invocations, exactly what arguments should be passed to /tmp/filearrange.sh (after variable expansion)?
Stop saying what you have tried and clearly explain what you want!
You have said that there are 10 lines in the 1st file and there are 20 other files. You have not shown what happens after the 10 lines have been read from the 1st file. The and so on gives no indication of whether the last 10 files are ignored, the 1st 10 files are repeated, or something completely different is desired.
I repeat: In a simplified example, if invfile contains:
and you invoke your script with the arguments:
I'm guessing that you want to invoke:
but I have no idea what you want to have happen with g3.
With this simplified example, please show us exactly what other invocations of /tmp/filearrange.sh should occur or, if I guessed wrong on the 1st two invocations, show us all of the invocations that your script should produce!
The invfile line1 means line 1 of invfile, and the g1 means file1, the g2 means file2. So for each line of invfile, there is a corresponding separate file that is the next argument for the command ( the -add -f processes each file).
Let me know if it still doesn't make sense.
The invfile line1 means line 1 of invfile, and the g1 means file1, the g2 means file2. So for each line of invfile, there is a corresponding separate file that is the next argument for the command ( the -add -f processes each file).
Let me know if it still doesn't make sense.
It doesn't make sense!
You said there are 10 lines in invfile. But you invoke /tmp/filearrange.sh with 13 of those 10 lines??? Please explain what is supposed to happen!
You said there are 20 files in your group of files (here called g1 through g20 for convenience), but you don't show what happens to g15 through g20 and you don't explain why g11 wasn't used with invfile line 11. Please explain how g* files are paired with lines, what happens if there aren't enough lines, what happens if there aren't enough g* files, and explain (in English) what is supposed to happen to g* files that don't have a matching line in invfile!
And, you have explained that invfile contains the 1st argument to be passed to /tmp/filearrange.sh, but you have yet to explain how the group of 20 files are passed to your script. Are the names of those files given on the command line to your bash script or are they in another file whose name is passed to your bash script? If their names are in a file, what is the name of that file?
I can't help you write a shell script if I don't understand what that script is supposed to do and how the script is going to be called.
Currently using the below script to being all compressed files .gz files from source folder and appending to the target txt file uncompressed.
Teh target txt file is getting too large in size, right now the size of the target txt file is almost 350GB
hadoop fs -text... (3 Replies)
Hi,
I will use below command for grep single string ("osuser" is search string)
ex: find . -type f | xarg grep -il osuser
but i have one more string "v$session"
here i want to grep in which file these two strings are present.
any help is appreciated,
Thanks in advance.
Gagan (2 Replies)
What is the syntax to use multiple input files in a SED command. i.e. substitute a word with a phrase in every file in a directory.
for every file in /usr/include that has the word "date" in the file
grep -l '\<date\>' /usr/include/*.h
find each occurrence of the word "time" in the file &... (3 Replies)
Hi,
I have a requirement where
I need to move Bunch of folders containing multiple files to another archive location.
i want to use mv command .I am thinking when we use mv command to move directory does it create directory 1st and then move all the files ?
e.g
source... (4 Replies)
Hi All,
We've been given the exercise below and I'm stumbling at the first block because we have to take in 20 student names and I don't know how to store them! :(
I know that I can create (initialize) 20 different char arrays but this seems wrong somehow...
What's the best way to store... (2 Replies)
i have a command like :
sed -n 's/^* /&/w even' <file
if i want to write to multiple files like
sed -n 's/^* /&/w zero two three' < file
its not working it is taking "zero two three" as a single file i want to write to 3 seperate files . pls can anyone help me (2 Replies)
I work with multiple archive files, mostly rar. I understand the basics of rar and zip. I'm looking for a way to decompress multiple rar files with a single command. Hopefully each file would be unrared into dir with same name as archive. I normally just do this manually, but sometimes I'm... (2 Replies)
Hi,
I needs to split *.txt files from single directory depends on the some mutltiple input values. i have wrote the code like below
for file in *.txt
do
grep -i -h "value1|value2" $file > $file;
done.
My requirment is more input values needs to be given in grep; let us say 50... (3 Replies)
Hi
I have following list of files at a path:
01.AR.asset
01.AR.index
01.AR.asset.vf
01.AR.asset.xv
I want to rename all these files as follows:
73.AR.asset.Z
73.AR.index.Z
73.AR.asset.vf.Z
73.AR.asset.xv.Z
Can any body give me a single command to acheive the above results.
... (5 Replies)
How do I perform a command to multiple files? For example, I want to look at all files in a directory and print the ones that do not contain a certain string. How do I go about doing this? (4 Replies)