An occasional blog about my recently discovered Linux gems!
File manipulation from the command line
Posted 11-03-2015 at 07:12 AM by myklmar
TEXT COMMANDS
To create file :: 'cat > (file name)'
After pressing Enter, you are not returned to the prompt. Instead, the cursor is placed on the next line, allowing you to enter text into your file. Type your lines of text, pressing Enter after each one.
When you are done, press Ctrl + D to exit the file and return to the prompt.
To verify file creation :: 'ls -l (file name)'
To view file :: 'cat (file name)'
To view files side by side :: ' paste file1.txt file2.txt file3.txt'
To add to a file :: 'echo (information) >> file1.txt
To create a new file with file1.txt file2.txt contents :: 'cat file1.txt file2.txt > newfile.txt '
To sort into alphabetical order :: 'sort file1.txt'
To sort into reverse order :: 'sort -r file1.txt'
To overwrite contents :: ' echo (new info) > file1.txt
To replace a word in the sentence :: ' sed s/word/newword/ file1.txt
To create file :: 'cat > (file name)'
After pressing Enter, you are not returned to the prompt. Instead, the cursor is placed on the next line, allowing you to enter text into your file. Type your lines of text, pressing Enter after each one.
When you are done, press Ctrl + D to exit the file and return to the prompt.
To verify file creation :: 'ls -l (file name)'
To view file :: 'cat (file name)'
To view files side by side :: ' paste file1.txt file2.txt file3.txt'
To add to a file :: 'echo (information) >> file1.txt
To create a new file with file1.txt file2.txt contents :: 'cat file1.txt file2.txt > newfile.txt '
To sort into alphabetical order :: 'sort file1.txt'
To sort into reverse order :: 'sort -r file1.txt'
To overwrite contents :: ' echo (new info) > file1.txt
To replace a word in the sentence :: ' sed s/word/newword/ file1.txt
Total Comments 0