Helpful Unix command used in ETL

1. To check processes own by user
$ps -ef | grep username

2. How to print a entire row in a '|' delimited file having a specific value in it's 2nd column.
$awk -F'|' '{if($2=="Spwcific Value")print $0;}' filename #$0 will print entire row

3. A '|' delimited file having 3 columns.How to print them in reverse order?
$awk -F'|'  '{ print $3, $2, $1 }' filename

4. Print row having similar value.
$awk '/desired value/' filename

5. How to replace a specific value with some particular value in a file in unix.
$sed 's/find what/replace with/g' filename

6. Search for a particular value in a file
$grep "value" filename

7. Search for a exact value in a file
$grep -w "value" filename

8. Search for a value except the specified value.
$grep -v "except value" filename

9. How to list a file in current directory
$ls -ltr #latest file will show at last(lower end)

10. How to see the current user
$whoami

11. How see my current working path
$pwd

12. To show every character on 2nd row.
$head -2 filename|tail -1|od -c

13. To show hexadecimal value of every character on 2nd row.
$head -2 filename|tail -1|od -h

14. Find any file on server

$find / -name serachvalue #instead of / (root) you can put from which path you want to search

15. Copy folder 
$cp -R source destionation #Folder will be copied recursively. And $mv comand can be used to rename.

16. To change ownership of file/folder
$chown -R owner.group FolderName

17. To change permission
$chmod -R 777 FolderName #777 denotes full permission "r-4,w-2,x-1"

18. Search content recursively
$grep -Ril "text-to-find-here" /
/*
i stands for ignore case (optional in your case).
R stands for recursive.
l stands for "show the file name, not the result itself".
/ stands for starting at the root of your machine.
*/

19. To check if connection is there between server on particular port
$telnet "destination ip" "port-nmber" #Connected message will be displayed if connectivity is available

20. To check if package installed on server
$rpm -qa| grep "package-name" #i.e. java

21. To search for package
$yum search  package-name #i.e. telnet,ksh

22. To install package
$yum install package-name #Must be as root user

No comments:

Post a Comment