LINUX working with bash Please help with 2 final questions: 1. Write a sequence of commands that would: (1) allow you to

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

LINUX working with bash Please help with 2 final questions: 1. Write a sequence of commands that would: (1) allow you to

Post by answerhappygod »

LINUX working with bash
Please help with 2 final questions:
1. Write a sequence of commands that would: (1) allow you to
nest a new folder named fruits inside the test folder and, (2) move
all the files inside of test into the fruits subfolder.
2. Write a sequence of commands to move all the files back from
fruits to the test folder, remove the
fruits folder and then rename test to
fruits.
Linux Working With Bash Please Help With 2 Final Questions 1 Write A Sequence Of Commands That Would 1 Allow You To 1
Linux Working With Bash Please Help With 2 Final Questions 1 Write A Sequence Of Commands That Would 1 Allow You To 1 (302.05 KiB) Viewed 26 times
Linux Working With Bash Please Help With 2 Final Questions 1 Write A Sequence Of Commands That Would 1 Allow You To 2
Linux Working With Bash Please Help With 2 Final Questions 1 Write A Sequence Of Commands That Would 1 Allow You To 2 (226.98 KiB) Viewed 26 times
Section 7: Renaming, moving, copying, and deleting files; removing directories Change back to your regular user account: # su XxourUserName. From the $ prompt: $ cd - Start in your user's home folder $ mkdir newtest $ cd test Make a new folder named newtest alongside of test Change to the test folder List its contents $ 1s You may wish to edit any/all of the files you just touched to add some text to them. To do this you should run a program called gedit. By default it's not installed in Mint Linux. To install gedit, you can type: sudo apt install gedit Linux will ask for yourUsername's password ('123') and then will take about 10-15 seconds to install gedit into Linux. To add some text to apple, for example, type: gedit apple When done click the Save button at the top of the gedit, window and then click on the Menu button next to Save and choose Quit. You can edit any of the other files in the same way. This next section shows you how to copy, move, rename, and delete files and folders. Make sure you're in the test folder when you begin: $ cd /test Changes you to the test folder if you're not already there $ mv grape peach Rename grape to peach $ ls See the change in the listing $ mv peach ~ $ ls $ 15 Move the peach file to your home folder Notice that it's gone from this listing Get a listing of the home folder (parent) Move peach back into test (here) Shows back up it in this directory $ mv/peach . $ 1s $ cp banana pear $ 1s Copy banana as a new file named pear See it in the listing $cp/newtest $ 1s Copy all the files in test to newtest Nothing's changed in the listing of test $ 1s/newtest Meanwhile, newtest was empty just a moment ago $ cd/newtest Change to the newtest folder $ 1s Show its listing $ rm apple Delete apple $ 1s Show that it's now missing $ rm p* Delete all files beginning with the letter 'p' Delete all files in newtest $ rm * $ cd $HOME Change back to your home folder Show a listing $ ls $ rm newtest This should produce an error message $ xmdir newtest Delete the newtest, folder $ 1s Show that it's gone in the listing $ mkdir newtest Re-create the newtest folder

$ ls Show it in the listing $ cp test/* newtest $ 1s newtest $ rmdix newtest $ rm newtest/* $ rmdir newtest $ ls Copy all the files from test into newtest Show all the copied files in newtest (This should produce an error message) Delete all the files in newtest Delete the newtest folder Show the listing Assume you are starting at your home folder. Write a sequence of commands that would: (1) allow you to nest a new folder named fruits inside the test folder and, (2) move all the files inside of test into the fruits subfolder. Write a sequence of commands to move all the files back from fruits to the test folder, remove the fruits folder and then rename test to fruits. These last two tasks bring you close to the realm of creating Linux shell scripts. We don't go into scripting in this class, but this is how close you are: here you typed and executed each command live, one at a time. In scripting you would type the commands, one per line, into a text file, save the file with a slightly special name and then you would tell Linux to run the file. At this point you'd be a Linux shell programmer!
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply