Linux Command Line Tools What will be outputted to the scree
Linux Command Line Tools.
What will be outputted to the screen after executing the following commands on the class Debian virtual machine?
1. echo -n \"aaaaabb\" | tr -d ’a’ | xxd -p (Hint: In ASCII, a is represented by bits 01100001 and b by 01100010.)
2. echo \"Dear Sir,\" > file1 echo \"I have deposited 5 million dollars US\" >> file1 echo \"in an account\" > file1 cat file1 | wc -l
Solution
echo -n \"aaaaabb\" | tr -d ’a’ | xxd -p
echo -n \"aaaaabb\" means, echo the text aaaaabb with no trailing new line characters.
And tr -d \'a\' will delete the specified characters. Therefore, after deleting a\'s, the result will be \"bb\"
And xxd means make a hexdump of the value bb.
Now the ASCII valud of \'b\' is 98 in decimal, and its hexadecimal equivalent is 62.
Therefore, xxd conversion of \'bb\' is 6262.
Therefore, the output of the code echo -n \"aaaaabb\" | tr -d ’a’ | xxd -p is: 6262.
echo \"Dear Sir,\" > file1 echo \"I have deposited 5 million dollars US\" >> file1 echo \"in an account\" > file1 cat file1 | wc -l
echo \"Dear Sir,\" > file1 means, echo the text Dear Sir, to the file file1.
echo \"I have deposited 5 million dollars US\" >> file1 means, append the text \"I have deposited 5 million dollars US\" to the file file1.
And therefore, now, the file1 will contain:
\"Dear Sir, I have deposited 5 million dollars US\"
echo \"in an account\" > file1 means, echo the text \"in an account\" to the file file1.
cat file1 is also added to file1.
And before, this, wc -l will list the number of lines.
Here, the number of lines in the file file1 is: 0`.
