In: Computer Science
Use CYGWIN TERMINAL to create this script. COPY AND
PASTE the screenshot.
Script 1:
1. Perform a ls -al on the files within the user's home
directory and save it to a file called ls.dat within your ~
directory
2. Save the tree information for the /home directory in
a file called tree.dat within your ~directory
3. Create a new directory in your home directory called
"backups"
4. Move the files you just created to the new
directory
5. Rename the files that you just moved to "ls.bu" and
"tree.bu".
1. ~ means home directory and ls will list all the files.-al are
attributes f ls comman and they mean
a --> list all the hidden file types
l --> to prit he long version ersion of the files (in
detail)
We use output edirection symbol (>) to save the o/p to new
file.
So the command would be
ls -al > ls.dat
2.Tree command will print the list of irectories in the given
path.It has many attributes like -a-->print hidden
files,-d-->print directories only etc
command:
tree ./home
to save this output use the redirection opertor,i.e >
So command willbe
tree ./home > tree.dat
3.To create new directory command used is "mkdir"
Command will be
mkdir backups
4&5
inorder to move to files to current directory we use 'mv' command
and to refer to current directory we use "./".
For renaming the file we can use the same mv command where we
expliciy give the target filename (which is the new name)
4.command will be as below
mv ls.dat ./backups
mv tree.dat ./backups
5. navigate to backups folder and give ls command to view the
renamed files
mv ls.dat ./backups/ls.bu
mv tree.dat ./backups/tree.bu
All the commands in sequential order for the above questions.