Question
In linux, write simple bash script that takes file name as command line argument, and prints out that file name ONLY if that file exists in the current directory (e.g. running "tests.sh test.txt" would print "yes" only if file test.txt exists).
#!/bin/bash

if [ -e $1 ]; then echo "yes" fi ^^^ not the use of -e to check existance of file, recall$1 is used to access first command line arg

Question
In linux, write simple bash script that takes file name as command line argument, and prints out that file name ONLY if that file exists in the current directory (e.g. running "tests.sh test.txt" would print "yes" only if file test.txt exists).
?

Question
In linux, write simple bash script that takes file name as command line argument, and prints out that file name ONLY if that file exists in the current directory (e.g. running "tests.sh test.txt" would print "yes" only if file test.txt exists).
#!/bin/bash

if [ -e $1 ]; then echo "yes" fi ^^^ not the use of -e to check existance of file, recall$1 is used to access first command line arg
If you want to change selection, open document below and click on "Move attachment"

7. Shell Scripting
file 10 times with 10 different extensions. As you can see, the variable $1 has a special meaning--it is the first argument on the command-line. Now let's get a little bit more sophisticated ( <span>-e test whether the file exists): 5 10 #!/bin/sh if test "$1" = "" ; then echo "Usage: backup-lots.sh <filename>" exit fi for i in 0 1 2 3 4 5 6 7 8 9 ; do NEW_FILE=$1.BAK-$i if test

#### Summary

status measured difficulty not learned 37% [default] 0

No repetitions