given something like this
find -type f -newermt "2011-05-26 15:40:35.088712" | xargs -n 1 bash -c fn=$0; set -- `ls -l $fn`; echo $7 $8 $9 $10;
I expect it to output the content in $10 when i try to echo $10 what really happens is it echos $1 along with 0, how do i make it echo $(10)
$1 is the argument passed for shell script. Suppose, you run ./myscript.sh hello 123. then. $1 will be hello. $2 will be 123.
$1 is the first command-line argument passed to the shell script. Also, know as Positional parameters. For example, $0, $1, $3, $4 and so on. If you run ./script.sh filename1 dir1, then: $0 is the name of the script itself (script.sh)
There are quite a few variables that can be used within scripts to evaluate arguments and display information about the script itself. $1, $2, $3 etc. represent the first, second, third, etc. arguments to the script.
dirname $0 takes a filename (in this case, $0 or the path where the shell found that file), and echo es the directory that it is stored in.
You need to use echo ${10}
to make that work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With