Skip to main content
added 198 characters in body
Source Link
rocky
  • 2k
  • 1
  • 13
  • 24

You were pretty close. First, you got right using $@ instead of $*.

You need to worry about shell expansion so don't use " unnecessarily as happened in the assignment. That will remove the boundaries between tokens. However you do need it around "@_".

So we have:

if [ $# -eq 0 ]; then
   echo "Usage is $0 <files to be tested>"
   exit
fi

for filetobetested in "$@"
do
    file "$filetobetested"
done

Lastly, my bash debugger http://bashdb.sf.net can help you follow stuff like this. Section 1.2 of the bashdb manual describes how to set PS4 to give more information from set -x tracing.

You were pretty close. First, you got right using $@ instead of $*.

You need to worry about shell expansion so don't use " unnecessarily as happened in the assignment. That will remove the boundaries between tokens. However you do need it around "@_".

So we have:

if [ $# -eq 0 ]; then
   echo "Usage is $0 <files to be tested>"
   exit
fi

for filetobetested in "$@"
do
    file "$filetobetested"
done

Lastly, my bash debugger http://bashdb.sf.net can help you follow stuff like this.

You were pretty close. First, you got right using $@ instead of $*.

You need to worry about shell expansion so don't use " unnecessarily as happened in the assignment. That will remove the boundaries between tokens. However you do need it around "@_".

So we have:

if [ $# -eq 0 ]; then
   echo "Usage is $0 <files to be tested>"
   exit
fi

for filetobetested in "$@"
do
    file "$filetobetested"
done

Lastly, my bash debugger http://bashdb.sf.net can help you follow stuff like this. Section 1.2 of the bashdb manual describes how to set PS4 to give more information from set -x tracing.

added 30 characters in body
Source Link
rocky
  • 2k
  • 1
  • 13
  • 24

You were pretty close. First, you got right using $@ instead of $*.

You need to worry about shell expansion so don't use "" unnecessarily as thathappened in the assignment. That will remove the boundaries between tokens. However you do need it around "@_".

So we have:

if [ $# -eq 0 ]; then
   echo "Usage is $0 <files to be tested>"
   exit
fi

for filetobetested in "$@"
do
    file "$filetobetested"
done

Lastly, my bash debugger http://bashdb.sf.net can help you follow stuff like this.

You were pretty close. First, you got right using $@ instead of $*.

You need to worry about shell expansion so don't use " unnecessarily as that will remove the boundaries between tokens. However you do need it around "@_".

So we have:

if [ $# -eq 0 ]; then
   echo "Usage is $0 <files to be tested>"
   exit
fi

for filetobetested in "$@"
do
    file "$filetobetested"
done

Lastly, my bash debugger http://bashdb.sf.net can help you follow stuff like this.

You were pretty close. First, you got right using $@ instead of $*.

You need to worry about shell expansion so don't use " unnecessarily as happened in the assignment. That will remove the boundaries between tokens. However you do need it around "@_".

So we have:

if [ $# -eq 0 ]; then
   echo "Usage is $0 <files to be tested>"
   exit
fi

for filetobetested in "$@"
do
    file "$filetobetested"
done

Lastly, my bash debugger http://bashdb.sf.net can help you follow stuff like this.

Source Link
rocky
  • 2k
  • 1
  • 13
  • 24

You were pretty close. First, you got right using $@ instead of $*.

You need to worry about shell expansion so don't use " unnecessarily as that will remove the boundaries between tokens. However you do need it around "@_".

So we have:

if [ $# -eq 0 ]; then
   echo "Usage is $0 <files to be tested>"
   exit
fi

for filetobetested in "$@"
do
    file "$filetobetested"
done

Lastly, my bash debugger http://bashdb.sf.net can help you follow stuff like this.