Quiz 2. Meta-characters andredirections.
Student name ___
What will the following command match?
This will list files containing 0 to 9 that do not start withalphabets a to z
For the questions 2, 3 and 4 tell what was changed: STDIN, STDOUTor STDERR?
$ cat file1
$ mailx user11 < letter
$ cat .profile > newprofile 2>&1
For the questions 5, 6 and 7 use the command cat filea, and perform the following:
Place the output of the command cat filea into the fileb and the errors into the filec.
Place the output of the command cat filea into the fileb and associate errors with the output.
$ catfileafileb2> fileb
Place the output of the command cat filea into the fileb and discard any error messages(do not display or store error messages)
$ cat filea fileb 2> /dev/null
Create a file named file22 using the command cat and redirections.
$ cat > file22
Create a file named ls.out using the command ls and redirections.
$ ls > ls.out
Create a file named date.out using the command date and redirections.
$ date > date.out
Calculate the number of files in your current directory using the ls and wc commands.
Calculate the number of files in the /usr directory using the ls and wc commands.
ls -1 /usr/ | wc -l
Calculate the number of users logged in using the who and wc commands.
who -l | wc -l
Create a message on the screen “This is the # of users on the system” using the result of the previous command.
$ cat Newfile
This is the who -l |wc -l of users on thesystem
Create a message on the screen “This is the # of files in the directory” using the result of the command in question 11.
$ cat Newfile
This is the ls -1 /usr/ | wc -l of files in the directory