The Command Line Part 4

Steven Klavins
2 min readFeb 21, 2020

Week 1 — The command line

Cat! Well concatenate at least, concatenating is the process in which you combine two things, in terminal this is done with the “cat” command.

Lets say we created a text file, “someText.txt” by typing “cat someText.txt” we can open the file and view its contents. The Windows equivalent to this would be “more” typed as follows “more someText.txt”.

Not only can we view the file, we can also as the title suggest concatenate (combine it with something else). By following the cat command with “cat > “someMoreText” we can add more (concatenate the file with new text), once done adding to the file hit enter followed by Ctrl+C to escape the command.

To do the same thing in Windows we use “echo >>” (this appends to the documents text) and “echo >” replaces the text, ensure you do this in the same directorate as the file. Example “echo “This is the text i’m adding”>> file_name.txt”.

In terminal there a few ways of displaying large bodies of text, by using the “less” (less longText.txt) command you’re able to scroll up and down the whole document, When finish viewing you simply hit “q” to quit.

If for example you want to view just the first 3 lines of a document use the “head -3” command ( head -3 long_text.txt), you can make this number and value you want. We can just as easily do this with “tail -3” to get the last 3 lines of the document, again this can be any value.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Steven Klavins
Steven Klavins

Written by Steven Klavins

Hi, I’m Steven, most call me Steve! I’m a programmer, musician, and artist. This blog contains various tutorials and posts related to software development.

No responses yet

Write a response