Topic 6 - Scripting and archiving Flashcards
this will create a .tar archive file named mylife.tar containing the life/ directory and its contents.
It will then proceed to verbose the files processed
what is the outcome of typing
tar –create –verbose –file=mylife.tar life/
into a linux terminal
this will decompress and extract the path and any files ending with burnet from the file mylife.tgz it will then print the files processed
what is the outcome of typing
tar –extract –verbose –file=mylife.tgz –wildcards ”*burnet“
into a linux terminal
this will decompress and extract the contents of the file mylife.tgz it will then print the files processed
what is the outcome of typing
tar –extract –verbose –file=mylife.tgz
into a linux terminal
does
tar
perform compression
no this command will only archive a directory and by itself does not perform any compression
although it is able to work with other commands that do perform compression
this is accomplished by using the following format:
Variable-name=value
No space should be used either side of the equals sign
in a linux script how do you declare a variable
no this command will only archive a directory and by itself does not perform any compression
although it is able to work with other commands that do perform compression
does
tar
perform compression
what was
tar (tape archive)
originally built for
this was originally developed to transfer files from very space limited hard drives to magnetic tapes and vice versa. However it became useful in creating an archive file that could be transported over the internet
lists the contents of the mylife.zip file (does not perform extraction)
what is the outcome of typing
unzip -l mylife.zip
into a linux terminal
what is the outcome of typing
unzip mylife.zip life/animals/
into a linux terminal
decompresses and extracts the directory and path life/animals/ from mylife.zip
what is the linux
tree
command used for
This is used to list the contents of a directory to the terminal window in a tree like format
what is the outcome of typing
bzip2 –verbose –keep mylife.tar
into a linux terminal
this will compress the file mylife.tar in the process preserving the original and creating a new file mylife.tar.bz2. it will then print information about the compression ratio
in linux how are
double quotes
handled
Anything wrapped inside these will be interpreted.
so spaces will be preserved, variables will be read and these are stripped after interpretation
decompresses and extracts the directory and path life/animals/ from mylife.zip
what is the outcome of typing
unzip mylife.zip life/animals/
into a linux terminal
what is
compression
this is the act of taking a file and reducing the number of bytes that it takes up, reducing storage space and bandwidth
this can be achieved by:
-
holding the argument place in a variable
- arg1=$1
- arg2=$2
-
hold all arguments given in a single variable
- args=$@
in linux what are the 2 ways that we can
read the arguments given by the user
in a linux script how do you declare a variable
this is accomplished by using the following format:
Variable-name=value
No space should be used either side of the equals sign
this will create an archive file and then compress it. the file will be named mylife.tgz and will contain the contents of the life/ directory. It will then continue to give verbose output about the archived files
what is the outcome of typing
tar –create –verbose –gzip –file=mylife.tgz life/
into a linux terminal
this will decompress and extract the file and path life/animals/insects from mylife.tgz it will then print the files processed
what is the outcome of typing
tar –extract –verbose –file=mylife.tgz life/animals/insects
into a linux terminal
what is the outcome of using
Read variable-name
in a linux script
this can be used to get input from the user and hold it in the variable variable-name
what is
archiving
this is the act of combining files and directories into a single file which can then be stored or copied
this will recursively compare the files in ~/work/life against the files in ~/extract/life
what is the outcome of typing
diff -r ~/work/life ~/extract/life
into a linux terminal
what is the outcome of typing
gzip mylife.tar
into a linux terminal
this will compress and replace the file mylife.tar to mylife.tar.gz
this can be achieved by enclosing the command and any options within brackets and appending a $ to the opening bracket
syntax
command-output=$(command-and-options)
in a linux script how can we hold the output of a command as a variable value
in a linux script what does the following accomplish
Today=$(date -I)
this will run the command
date -I
and the output will be stored as the value to the variable today