Redirection: myname.txt

Creating myname.txt

Using the echo command and the redirection write operator >, create a new file named myname.txt that contains your first name.

Solution

CLICK FOR ANSWER
echo "Paul" > myname.txt

Overwrite myname.txt

Using the echo command and the redirection write operator >, overwrite the myname.txt that contains a more informative line like firstName=[YOUR FIRST NAME].

Solution

CLICK FOR ANSWER
echo "firstName=Paul" > myname.txt

Appending to myname.txt

using the echo command and the redirection append operator >>, append your last name as a new line to the myname.txt file like lastName=[YOUR LAST NAME].

Solution

CLICK FOR ANSWER
echo "lastName=Matthews" >> myname.txt

Verification of myname.txt

How can you verify that myname.txt matches the following structure?

firstName=[YOUR FIRST NAME]
lastName=[YOUR LAST NAME]
CLICK FOR ANSWER

By using the cat command.

cat myname.txt

Output:

firstName=Paul
lastName=Matthews