Posts Tagged With: file

Compare contents of two files

Tagged with: , , , , ,

Compare contents of two files by deleting only unique lines from ‘file1′


comm -1 file1 file2
No Comments »

Copy all Txt Files

Tagged with: , , , , , ,

Find and copy all files with ‘.txt’ extention from a directory to another


find /home/binnyva -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents
No Comments »

Sort and Unique

Tagged with: , , , , , ,

Sort contents of a file and remove repeated lines


sort file.txt | uniq
1 Comment »

View some lines in a file

Tagged with: , , , ,

View from 1th to 5th line


sed -n '1,5p;5q' example.txt
No Comments »

Encrypt/Decrypt using GPG

Tagged with: , , , ,

Encrypt/Decrypt a file with GNU Privacy Guard - GPG.


#Encrypt
gpg -c file

#Decrypt
gpg file.gpg
1 Comment »

Find number of lines in a file

Tagged with: , , , , ,

Find the number of lines in a file using this command…


cat -n file
OR
wc -l file
No Comments »

Change Ownership of a File

Tagged with: , , , , , ,

Change user and group ownership of a file


chown user:group file
No Comments »

Change File Encoding

Tagged with: , , , , , ,

Creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding.


iconv -f fromEncoding -t toEncoding inputFile > outputFile
No Comments »

See Mounted File Systems

Tagged with: , , , , , ,

Shows all mounted file systems in Linux


cat /proc/mounts
No Comments »

Reverse a File

Tagged with: , , , , , ,

This commands reverses a file in linux - the last line will be the first…


tac file.txt

tac = reverse of cat

No Comments »