If n>9 special syntax is needed. This example is snipped from my script which uses dcfldd to write image to pendrives: dcfldd if=$1 of=$2 of=$3 of=$4 of=$5 of=$6 of=$7 of=$8 of=$9 of=${10} of=${11} bs=64K status=on
$1 is the imagefile’s name, arguments 2 to 11 are the /dev/sdX names, where to flash the image. Note the ${10}, which is not $10, as it could be expected.
Hi, I tried to answer the question of your exercise 1: can I ask you a help in making the code cleaner?
#!/bin/bash
arguments=$@ #transforming the arguments in an array:
IFS=’ ’ read -r -a argumentsArr <<< $arguments
length=$#
i=$length
while [ $i -ge 0 ]
do
echo ${argumentsArr[$i]}
((i=i-1))
done
Also, why isn’t this working: ?
#!/bin/bash #transforming the arguments in an array:
IFS=’ ’ read -r -a argumentsArr <<< $@
length=$#
while [ $length -ge 0 ]
do
echo ${argumentsArr[$length]}
((length=length-1))
done
This gave me some trouble but i got it to work eventually. I’m sure it could be cleaned up, maybe get rid of file_path=“$path” and just put $path in directly?
I also added the continue prompt for when we learn if/then, I want to add “if no then exit” and "if no then go to “what is the file path”.
#!/bin/bash
#input
echo “Find line and word count for files”
echo “Continue?”
read
echo “What is the File Path?”
read path
echo “Is $path correct?”
read