I'm new, and joined to ask a question about a script (first answer at How to disable “Extraction completed successfully” dialog in Nautilus?) and could not "comment" beneath it (no reputation) and posting it via Answer didn't seem right.
So the question is about using double-digits or, even better, specifying ALL in a script like the following:
#!/bin/bash
p1=$1
p2=$2
p3=$3
p4=$4
p5=$5
p6=$6
if [[ $p2 == *"notify"* ]]; then
p2=""
fi
/usr/bin/file-roller_orig $p1 $p2 $p3 $p4 $p5 $p6
The script is to disable the successful extraction popup using the File Roller context-menu option in Nautilus, and it successfully does that. However it is limited to only extracting up to 4 archives at once. Since I often extract a dozen or more files at once, and seeing that p2=$2 was tied to the notification, I experimented with adding p7=$7 etc (I am no CLI guru) and it did indeed extract more than 4, but after p9=$9 (which extracts 7 archives), it stopped there – which I thought might happen as in Gedit the last digit at the end of p10=$10 etc was a different colour to the rest (I figured that wasn't good).
So how do I make entries after p9=$9 or, much better still, get the script to tell file-roller to extract all the archives that were selected? The latter would be ideal, as even if I can make it extract a dozen files at once, I'm bound to want to extract more than that at some point, and not have to do it in batches. Many thanks in advance for your answers. Cheers.
Best Answer
You can use
"$@"
to get all parameters andshift N
to remove N arguments.Quoting variables with double quotes (such as
"$1"
) is a good idea to ensure bash doesn't try and use one variable as multiple arguments.Although using
$@
is better, it's possible to use${10}
to access the tenth argument.