exam questions

Exam 200-901 All Questions

View all questions & answers for the 200-901 exam

Exam 200-901 topic 1 question 168 discussion

Actual exam question from Cisco's 200-901
Question #: 168
Topic #: 1
[All 200-901 Questions]

FILL BLANK -
Fill in the blanks to complete the Bash script in which each file in a directory is renamed to its SHA256 hash?

TARGET_DIR=/usr/local/certs -
for f in '__________ __________'; do
__________ $f' openssl sha -sha256 -r < $f | cut -f1 -cl' ''

Show Suggested Answer Hide Answer
Suggested Answer: See explanation below.
TARGET_DIR=/usr/local/certs -
for f in '/usr/local/certs'; do
echo $f' openssl sha -sha256 -r < $f | cut -f1 -cl' ''

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
valbonarexhepi
Highly Voted 1 year, 5 months ago
ls $TARGET_DIR mv
upvoted 34 times
...
batmantm
Highly Voted 1 year, 5 months ago
for f in : ls $TARGET_DIR mv
upvoted 8 times
...
mtempeo
Most Recent 10 months, 3 weeks ago
ls $TARGET_DIR mv "
upvoted 2 times
...
[Removed]
1 year, 2 months ago
ls $TARGET_DIR mv
upvoted 2 times
...
blalw
1 year, 3 months ago
for f in 'ls $TARGET_DIR' do mv..., not sure where it is correct, from my experience the most similar i can run is: for f in $(ls $TARGET_DIR) do mv.... can someone elaborate? thanks
upvoted 1 times
flox
1 year, 2 months ago
use ` instead '
upvoted 3 times
...
...
Elvkoo
1 year, 4 months ago
$TARGET_DIR/* mv
upvoted 5 times
...
Sliking
1 year, 4 months ago
I don't get this script... Shouldn't it be something like this: for f in *; do mv $f $(openssl sha256 -r < $f | cut -d " " -f 1); done I tried with 'ls $TARGET_DIR' and it just prints the command which results in an error: "mv: cannot stat 'ls': No such file or directory" Regarding the cut command we can use either -f or -c according to documentation, why are they using both? Also the default delimiter is TAB which would result in the string having 'stdin' at the end. We need to change that with the -d option.
upvoted 2 times
geex
1 year, 2 months ago
Single quotes (') in this example most probably should be back-ticks (`). But essentially it comes down to: - list files in directory (eg. `ls $TARGET_DIR`) - move each file (eg. `mv $f `openssl....`)
upvoted 3 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago