do the assignment first. reading the answer is not the same as doing it, and u will feel like u learned it when u didn’t.
# 1
ls ~
echo $?
ls ~/nope
echo $?
# 2
echo "first line" > notes.log
# 3
echo "second line" >> notes.log
cat notes.log
# 4
cat missing.txt 2> errors.log
cat errors.log
# 5
ls ~ | wc -l
# 6
ls ~ | grep "D" | wc -l
# 7
ps aux | grep "bash"
# 8
mkdir practice && cd practice
# 9
sleep 30 &
jobs
fg
# then ctrl + c to kill it
# 10
sleep 30
# press ctrl + z
bg
jobsoutput of 1:
0
2
output of 3:
first line
second line
output of 4:
cat: missing.txt: No such file or directory
output of 9:
[1] 4517
[1]+ Running sleep 30 &
sleep 30
- in step 3, if u used
>instead of>>u would have lostfirst linecompletely. - in step 4, notice that nothing appeared on ur screen when u ran the
cat. that is the point, the error went into the file instead. - in step 7, remember one of the lines u see is the
grepitself. - in step 8,
&&is the answer and;is the wrong one. if themkdirfails because the folder already exists,;would still run thecd. - in step 10, if u stop after
ctrl + zand never typebg, thatsleepis paused and not running.jobswould sayStoppedinstead ofRunning. try it both ways and look at the difference.