Basic Unix/Linux Commands 1. Make a new directory called mac232 2. Change you lo
ID: 3751314 • Letter: B
Question
Basic Unix/Linux Commands 1. Make a new directory called mac232 2. Change you location to this directory. 3. Make new directory called hw1. You should specify a flag to print out a message after the directory is created (i.e., use 'man' pages to find this flag) 4. Copy the directory /home/walter/mac232/hwl and all its subcontents to your current location 5. Change your location to this directory (hwl). 6. List only files ending in txt using the long format (hint use 'man' to find out to list files using the long format). 7. List only files ending in 'jpg' Again, use the long format and in addition, the files should be sorted by modification time. 8. Remove files with file' and ending in 'jpg'. You should specify an argument that forces the system to ask you if you want to delete each file. 9. Display the content of the file 'print-file.txt 10. Rename the file 'mac232-9.txt' to 'print-file.txt. This will remove the old print-file.txt'. You should specify an argument that will backup this old file. 11. Display the content of the new 'print-file.txt'. Each line should be numbered 12. Move all the contents from 'tmp/ to the current location. 13. Remove the directory 'tmp/ 14. List all files using the long format. The files should be sorted by file size. 15. Use the man command to search all man pages to find the command(s) or description contain printfExplanation / Answer
1) Make a new directory called mac232
Sol) mkdir mac232
2) Change you location to this directory
Sol) cd mac232
3) Make new directory called hw1. You should specify a flag to print out a message after the directory is created (i.e., user 'man' pages to find this flag)
Sol) mkdir -v hw1
created directory hw1
Note: -v Verbose output. Print a message for each created directory
4) Copy the directory /home/walter/mac232/hw1 and all its subcontents to your current location.
Sol) cp *.* /home/walter/mac232/hw1
5) Change your location to this directory(hw1)
Sol) cd /home/walter/mac232/hw1
6) List only files endings in '.txt' using the long format (hint use 'man' to find out to list files using the long format).
Sol)
1) ls -l *.txt List with long format - show permissions
2) ls -la *.txt List long format including hidden files
3) ls -lh *.txt List long format with readable file size
4) ls -ls *.txt List with long format with file size
7) List only file ending in '.jpg'. Again, use the long format and in addition, the files should be sorted by modification time.
Sol) ls -l -t *.jpg
8) Remove files with 'file' and ending in '.jpg'. You should specify an argument that forces the system to ask you if you want to delete each file.
Sol) rm -i *.jpg
9) Display the content of the file 'print-file.txt'
Sol) cat print-file.txt
10) Rename the file 'mac232-9.txt' to 'print-file.txt'. This will remove the old 'print-file.txt'. You should specify an argument that will backup this old file.
Sol) mv -b --suffix=.bak mac232-9.txt print-file.txt
11) Display the content fo the new 'print-file.txt'. each line should be numbered.
Sol) cat -n print-file.txt
12) Move all the contents from 'tmp/' to the current location.
Sol) mv tmp/ ..
13) Remove the directory 'tmp/'
Sol) rmdir tmp
or
rm -rf tmp/
14) List all files using the long format. The files should be sorted by file size
Sol) ls -lS
15)Use the man command to search all man pages to find the command or description contain 'printf'
Sol) man -k printf
OUTPUT
asprintf (3) - print to allocated string
dprintf (3) - print to a file descriptor
fprintf (3) - formatted output conversion
fwprintf (3) - formatted wide-character output conversion
printf (1) - format and print data
printf (3) - formatted output conversion
snprintf (3) - formatted output conversion
sprintf (3) - formatted output conversion
...