July 2018
Beginner
264 pages
8h 9m
English
Let's start our activity as follows:
#!/bin/bashFILE_NAME=$1echo $FILE_NAMEls $FILE_NAME
$ touch TEST.txt$ mkdir new_dir/$ bash bad_input.sh "."$ bash bad_input.sh "../"
#!/bin/bashFILE_NAME=$1# first, strip underscoresFILE_NAME_CLEAN=${FILE_NAME//_/}FILE_NAME_CLEAN=$(sed 's/..//g' <<< ${FILE_NAME_CLEAN})# next, replace spaces with underscoresFILE_NAME_CLEAN=${FILE_NAME_CLEAN// /_}# now, clean out anything that's not alphanumeric or an underscoreFILE_NAME_CLEAN=${FILE_NAME_CLEAN//[^a-zA-Z0-9_.]/}# here you should check to see if the file exists ...Read now
Unlock full access