πŸ‘¨β€πŸ’»
Jawad's Notes
  • πŸ‘¨β€πŸ«INFOSEC
    • πŸ•ΈοΈWeb
      • Burp Suite: Setting Foxyproxy
      • XSS
      • Wappalyzer
      • Directory Traversal
      • LFI
        • PHP Wrappers
        • RFI
      • Reverse Shell
        • Command Injection Quick Tips
      • File Upload
      • WPScan
      • SQL Injection
        • Schemas
        • SQLmap
        • MSSQL
        • MySQL
        • PostgreSQL
    • πŸ”§Tools
      • Whois
      • DNSRecon
      • DNSenum
      • nslookup
      • Netcat
        • Powercat
      • Nmap
        • Nmap Scripting Engine
        • Test-NetConnection
        • Grep
      • Server Message Block (SMB)
      • SNMP
      • SMTP
      • ExifTool
      • Search Engine Hacking
      • Source Control Hacking
      • Nessus
      • Canarytokens
      • Qualys SSL Server Test
      • Security Headers
      • theHarvester
      • Shodan
      • Gobuster
        • Dirb
      • Searchsploit
      • Password Cracking
        • Hashcat
        • John The Ripper
        • Hydra
        • hashID
        • CPU vs GPU
    • 🐧Linux
      • Symbols
      • cat
      • curl
      • openvpn
      • tcpdump
      • Remote Desktop
      • SmbShare
      • Tmux
      • Convert Windows-style line endings (CRLF) to Unix-style (LF)
      • SSH
    • πŸ–₯️Macros in Office
    • 🍎Enhancing Your MacOS Terminal Experience
    • 🚩CTF
      • SQL Injection
        • WHERE clause allowing retrieval of hidden data
        • Allowing login bypass
        • UNION attack, determining the number of columns returned by the query
        • UNION attack, finding a column containing text
        • UNION attack, retrieving data from other tables
        • UNION attack, retrieving multiple values in a single column
        • Querying the database type and version on Oracle
Powered by GitBook
On this page
  1. INFOSEC
  2. Linux

cat

The cat command in Linux and Unix-like operating systems is a short form for "concatenate." It's one of the most frequently used commands and serves multiple purposes, primarily to read, create, and concatenate files. The basic functionality of cat is to display the content of files to the standard output (the terminal screen), but it can do more when combined with other commands or used with its options.

Basic Usage

  • Displaying the contents of a file: To read and display the contents of a file on the terminal, you can use cat followed by the filename. For example, cat myfile.txt will display the contents of myfile.txt.

Creating a File

  • Creating a new file: You can also use cat to create a new file by redirecting its output to a file. For example, cat > newfile.txt will create a new file named newfile.txt. You can then type the content of the file, and once you're done, press CTRL+D to save and exit.

Concatenating Files

  • Concatenating files: The cat command can concatenate the contents of multiple files and display the result. For example, cat file1.txt file2.txt will display the contents of file1.txt followed by the contents of file2.txt. You can also redirect the output to create a new file containing the concatenated contents of the files: cat file1.txt file2.txt > combined.txt.

Appending Content

  • Appending content to an existing file: You can append the content of one or more files to the end of another file using the >> redirection operator. For example, cat file3.txt >> combined.txt will append the content of file3.txt to the end of combined.txt.

Other Useful Options

  • -n: Numbers all output lines, which is useful for viewing or debugging files with content that needs to be referenced by line number.

  • -s: Suppresses repeated empty output lines, condensing the output to make it easier to read.

  • -E: Displays a $ at the end of each line, making it easier to see line breaks, especially in files with mixed content or trailing spaces.

Example Commands

  • Display file content: cat filename.txt

  • Create a file: cat > filename.txt

  • Concatenate multiple files: cat file1.txt file2.txt > mergedfile.txt

  • Append file content: cat additional.txt >> existingfile.txt

  • Number lines: cat -n file.txt

cat is a powerful tool for handling text data and is often used in conjunction with other commands and pipes (|) to perform more complex tasks like searching within files, sorting file contents, and more.

PreviousSymbolsNextcurl

Last updated 1 year ago

πŸ‘¨β€πŸ«
🐧