Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions 161602104陈后全
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

Exercises1
1. Create a new directory called workbench in your home directory.
Solution:
mkdir /home/workbench

2. Without changing directories create a file called readme.txt inside of workbench.
Solution:
touch /home/workbench/readme.txt

3. Append the numbers 1, 2, and 3 to readme.txt so that each number appears on it’s own line.
Solution:
echo -e “1\n2\n3”>/home/workbench/readme.txt

4. Print readme.txt to the command line.
Solution:
cat /home/workbench/readme.txt

5. Use output redirection to create a new file in the workbench directory called list.txt which lists the files and folders in your home directory.
Solution:
ls 1>/home/workbench/list.txt

6. Find out how many characters are in list.txt without opening the file or printing it to the command line.
Solution:
wc -m < /home/workbench/list.txt


Exercises2
1. Create a file called message.txt in your home directory and move it into another directory.
Solution:
touch /home/message.txt
mv message.txt /home/workbench/

2. Copy the message.txt you just moved into your home directory.
Solution:
cp /home/workbench/message.txt /home

3. Delete both copies of message.txt. Try to do this without using rm.
Solution:
find /home -name “message.txt” -delete



Exercises3
1. Use man to look up the flag for human-readable output from ls.
Solution:
man ls
ls -h

2. Get help with man by typing man man into the console.
Solution:
man man

3. Wouldn’t it be nice if there was a calendar command? Use apropos to look for such a command, then use man to read about how that command works.
Solution:
apropos calendar
man cal

Exercises 4
4. Before I organized the photos by year, what command would have listed all of the photos of type .png?
Solution:
find -name "*.png"

5. Before I organized the photos by year, what command would have deleted all of my hiking photos?
Solution:
find -name “*hiking*” -delete

6. What series of commands would you use in order to put my figures for a data science course and the pictures I took in the lab into their own folders?
Solution:
mkdir “Figures For Data Science”
mkdir “Pictures Took In Lab”
find -name “*Data*Science*” -exec mv ‘{}’ “Figures For Data Science” \;
find -name “*figure*lab*” -exec mv ‘{}’ “Pictures Took In Lab” \;