Useful Centos Commands

#Extract unrar files

[rsengodan@contossrv tmp]$ unrar e Test.rar

UNRAR 5.00 beta 3 freeware      Copyright (c) 1993-2013 Alexander Roshal

Extracting from Test.rar

Extracting  performance.log                                           OK
Extracting  systemerror.log                                            OK
All OK
[rsengodan@centossrv tmp]$ ls -ltr

#Find string in current and subdirectories

find . -exec grep “www.utm” ‘{}’ \; -print –> to find out the string

#Copy files to remote server using scp utility

[rsengodan@centossrv tmp]$ scp -r test.log test1.log rsengodan@10.21.100.101:/tmp

#Extract unique token from file

[21 Mar 2017 11:45:53:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/ravi/user.xml (No such file or directory)
[21 Mar 2017 11:45:54:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/kumar/user.xml (No such file or directory)
[21 Mar 2017 11:45:54:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/guna/user.xml (No such file or directory)
[21 Mar 2017 11:45:54:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/aadhav/user.xml (No such file or directory)
[21 Mar 2017 11:45:54:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/moni/user.xml (No such file or directory)

cat sample.log | grep “java.io.FileNotFoundException:” | awk ‘{print $9;}’ | sort | uniq

output:

/usr/users/ravi/user.xml
/usr/users/kumar/user.xml
/usr/users/guna/user.xml
/usr/users/aadhav/user.xml
/usr/users/moni/user.xml

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s