#cat
Print a file
cat file [file2 ...]cat notes.txtPrint the whole file
cat -n script.shPrint with line numbers
cat a.txt b.txt > all.txtJoin two files into a new file
Most of what you do on a Linux server is reading text: logs, configs, notes. In this video, you'll learn the commands that make that fast: cat, head, tail, grep, wc, and the pipe that joins them. We're already connected with SSH Command, and the Shell view is open. Everything you type here runs on the server. cat prints a whole file to the screen. Try it on notes dot txt. It's perfect for short files. For longer files, head shows just the beginning. By default you get ten lines, and dash n lets you choose how many. Here are the first three lines of the application log. tail does the opposite. It shows the end of a file, which is where the newest log entries are. Here are the last three lines. grep searches for text. Give it a word and a file, and it prints only the lines that contain it. Let's find every error in the log. Add dash i to ignore upper and lower case, and dash n to show line numbers. And dash c simply counts the matching lines. wc counts things. With dash l, it counts lines. This log has thirty. Now the clever part. The pipe character sends the output of one command into the next. Here, grep finds the errors, and wc counts them. Five errors, in a single line. Pipes work with any text command. Let's see which requests the web server gets most often. sort puts the lines in order, uniq dash c counts the repeats, sort dash r n ranks them, and head keeps the top three. That's cat, head, tail, grep, wc, and the pipe. Each one has a full guide, with more examples, at ssh command dot com, under text commands. SSH Command is free for personal use. The link is in the description. See you in the next one.
catPrint a file
cat file [file2 ...]cat notes.txtPrint the whole file
cat -n script.shPrint with line numbers
cat a.txt b.txt > all.txtJoin two files into a new file
lessRead a long file page by page
less fileless /var/log/syslogOpen a log; use arrows or Space to move, / to search, q to quit
less +F app.logOpen and follow new lines as they arrive (Ctrl+C to stop following)
headShow the first lines
head [-n N] filehead -n 5 data.csvFirst five lines
head -c 100 file.binFirst 100 bytes
tailShow the last lines
tail [-n N] filesudo tail -n 50 /var/log/nginx/error.logLast 50 lines (most files in /var/log need sudo)
sudo tail -f /var/log/syslogKeep watching new lines as they are added (Ctrl+C to stop)
tail -F app.logSame, but keeps going if the log is rotated
nanoSimple text editor
nano filenano /etc/hostsOpen a file (use sudo for system files)
vimPowerful text editor
vim filevim config.ymlOpen a file. Press i to type, Esc to stop typing
vim +42 app.pyOpen at line 42
teeShow output and save it too
command | tee filels -l | tee list.txtPrint the list and also write it to list.txt
echo "127.0.0.1 test" | sudo tee -a /etc/hostsAppend a line to a root-owned file (plain > would fail)
wcCount lines, words and bytes
wc [-l] [-w] [-c] filewc -l access.logCount lines
ls | wc -lCount how many files are in the folder
nlNumber lines
nl filenl script.shPrint the file with numbered lines
SSH Command is a desktop app for Mac, Windows and Linux that puts a real terminal, SFTP file panes, a sudo switch and a searchable Linux command finder in one window. Type what you want to do, and send the command to your server with one click.
Download free Windows commands with examples SFTP & FTP client