Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when i try to echo $10 it becomes echo $1 0 [duplicate]

Tags:

bash

echo

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)

like image 688
Doboy Avatar asked May 26 '11 22:05

Doboy


People also ask

What does echo $1 mean?

$1 is the argument passed for shell script. Suppose, you run ./myscript.sh hello 123. then. $1 will be hello. $2 will be 123.

What does $1 mean in a shell script?

$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)

What are the variables $1 $2 $3 etc used for?

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.

What is Dirname $0?

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.


1 Answers

You need to use echo ${10} to make that work.

like image 166
Carl Norum Avatar answered Sep 17 '22 14:09

Carl Norum