Sponsored Content
Top Forums Shell Programming and Scripting Inputting multiple files into one command Post 302835065 by newbie2010 on Sunday 21st of July 2013 04:52:39 PM
Old 07-21-2013
Inputting multiple files into one command

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
Code:
invfile contents (variable x)     20 files (these files are separate files) ($filex)
inventory-usage-4                  inventory.txt
inventory-usage-3                  shelflist.txt
inventory-usage-4                  stocklist.txt
etc                                           etc,  up to 20 files

So
Code:
/tmp/filearrange.sh $x  -add $filex

looks like this (example)

/tmp/filearrange.sh inventory-usage-4 -add inventory.txt
/tmp/filearrange.sh inventory-usage-3 -add shelflist.txt

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:

Code:
exec 3<$filex
where filex= `cat /tmp/*.txt`

and I can't get this working.


Code:
while read i && read x<&3
do
  /tmp/filearrange.sh "$i" -add -f "$filex"
done < /tmp/ exec 3<$filex

I'm really confused about this in bash. Any help is appreciated.

Last edited by Scrutinizer; 07-21-2013 at 06:14 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Perform a command to multiple files

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)
Discussion started by: mcgrawa
4 Replies

2. Shell Programming and Scripting

how to rename multiple files with a single command

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)
Discussion started by: tayyabq8
5 Replies

3. Shell Programming and Scripting

Splitting input files into multiple files through AWK command

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)
Discussion started by: arund_01
3 Replies

4. UNIX for Dummies Questions & Answers

Unrar Multiple Files with Command

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)
Discussion started by: dobbs
2 Replies

5. Shell Programming and Scripting

how to use multiple files in sed with w command

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)
Discussion started by: santosh1234
2 Replies

6. Homework & Coursework Questions

C++ inputting multiple strings

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)
Discussion started by: pondlife
2 Replies

7. Shell Programming and Scripting

using mv command for moving multiple files in a folder

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)
Discussion started by: rkmbcbs
4 Replies

8. Shell Programming and Scripting

SED command using multiple input files

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)
Discussion started by: sheoguey
3 Replies

9. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

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)
Discussion started by: gagan4599
2 Replies

10. Shell Programming and Scripting

Using -text command and creating multiple files

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)
Discussion started by: cplusplus1
3 Replies
DH_UCF(1)							     Debhelper								 DH_UCF(1)

NAME
dh_ucf - register configuration files with ucf SYNOPSIS
dh_ucf [debhelperoptions] [-A] [-n] [file...] DESCRIPTION
dh_ucf is a debhelper program that is responsible for generating the postinst and postrm commands that register files with ucf(1) and ucfr(1). FILES
debian/package.ucf List pairs of source and destination files to register with ucf. Each pair should be put on its own line, with the source and destination separated by whitespace. Both source and destination must be absolute paths. The source should be a file that is provided by your package, typically in /usr/share/, while the destination is typically a file in /etc/. A dependency on ucf will be generated in ${misc:Depends}. OPTIONS
-A, --all Install all files specified by command line parameters in ALL packages acted on. -n, --no-scripts Do not modify postinst/postrm scripts. Turns this command into a no-op. file ... Install these info files into the first package acted on. (Or in all packages if -A is specified). NOTES
Note that this command is not idempotent. dh_prep(1) should be called between invocations of this command. Otherwise, it may cause multiple instances of the same text to be added to maintainer scripts. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> Jeroen Schot <schot@a-eskwadraat.nl> 11.1.6ubuntu2 2018-05-10 DH_UCF(1)
All times are GMT -4. The time now is 07:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy