Compare contents of two files
Tagged with: comm, command, compare, diff, file, Linux
Monday, June 23rd, 2008 10:03 PM
Compare contents of two files by deleting only unique lines from ‘file1′
comm -1 file1 file2
Compare contents of two files by deleting only unique lines from ‘file1′
comm -1 file1 file2
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
Sort contents of a file and remove repeated lines
sort file.txt | uniq
View from 1th to 5th line
sed -n '1,5p;5q' example.txt
Encrypt/Decrypt a file with GNU Privacy Guard - GPG.
#Encrypt
gpg -c file
#Decrypt
gpg file.gpg
Find the number of lines in a file using this command…
cat -n file
OR
wc -l file
Change user and group ownership of a file
chown user:group file
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
Shows all mounted file systems in Linux
cat /proc/mounts
This commands reverses a file in linux - the last line will be the first…
tac file.txt
tac = reverse of cat