For testing i create at my Linux-System the file list.txt
. In there are numbers like:
4 1 5 2 3
(sometime there are more or less numbers)
How do i run these numbers with fallocate?
fallocate -l 1stnumberG file1
fallocate -l 2ndnumberG file2
fallocate -l 3rdnumberG file3
....
i think about something like
declare -i counter ; counter=1 ; for i in "'seq 1 $(wc -w list.txt | cut -c 1)'" ; do fallocate -l ${i}G "file$counter" ; (( ++ counter )) ; done
fallocate: unerwartete Anzahl an Argumenten
declare -i counter ; counter=1 ; for i in "'seq 1 $(wc -w list.txt | cut -c 1)'" ; do fallocate -l ${i}G "file$counter" ; (( ++ counter )) ; done < $(cat list.txt)
V: $(cat list.txt): Mehrdeutige Umlenkung.
but i didt work....
echo $i
? If not, what does it loop over and what does that tell you? Does the innermost command substitution (wc | cut
) print the right thing? If not, consider what the commands there do individually, and if that's what you want here.echo $i
say'seq 1 5'
. dont know the right way how to give fallocate the numbers from list.txtecho $i
returns the text of the command tell you? That Bash didn't execute what it sees as a text. You already used command substitution, which is a way to execute text as a command. Also drop the single quotes, otherwise Bash will look (and most probably fail) for command literally namedseq 1 5
, with spaces, if substitution is used outside the quotes.< $(cat list.txt)
looks like it was stiched together from random parts. Command substitution (essentially) puts the output of the command on the command line, sols file.txt
is the same asls $(echo file.txt)
, and I don't think you had a filename inlist.txt
. If you want to redirect the contents of the file to the loop, you just need< list.txt
. But there's nothing in the loop to read stdin anyway. I might suggest reading e.g. mywiki.wooledge.org/BashGuide or another guide on shell scripting.