1. To grep the pattern using awk command:
awk '{print $1,$2,$3,$4,$5,$6,$7}' <file_name> | sort | uniq -c | sort -nr | grep <pattern>
2. To grep the pattern from zipped(*.gz) file using awk command:
awk '{print $1,$2,$3 }' <(gzip -dc <zipped_file_name>)
| sort uniq -c | sort -nr | grep <pattern>
3. Copy the file from one server to another:
scp -r
root@10.200.134.243:/<source-path>
root@10.200.134.195:/<destination-path>
4. To monitor the log:
tail
–f /var/log/atg/server.log
5. To find string the directory:
grep
-nr "string" <my_directory>
6. To find directory from the sub directory:
find -type d -name ‘my_directory’
7. To find the file from the sub directory:
find -type f -name ‘my_file’
8. To find the site
response time :
curl
-s -w %{time_total}\\n -o /dev/null <URL>
9. upload file using cURL command
curl –u ftpusername:ftppassword –T “{file1.txt, file2.txt,file3.txt…}”
<url where to upload>
10. To unzip the zipped file to the specific path :
unzip *.zip -d
/destination path
11. To replace the string to another string in a file in vi mode:
Follow the following steps:
a) vi <file name>
b) esc + :%s/<old_string>/<new_string>/+ press enter
c) esc + wq+ enter ==> to save
12: Read the data one by one row wise from csv file:
while read p;
do
if [ ! -z "$p" -a "$p" != " " ]; then
IP=`echo $p | cut -d',' -f1`
PORT=`echo $p | cut -d',' -f2`
echo "ip= $IP, Port= $PORT"
fi
done < IP_PORT.csv
13. Remove the pattern for the given specific condition :
if two pattern should not be in same row, delete it. like pattern1 and pattern2 or pattern2 and pattern3 should not be together etc.
sed -i "/<pattern1> <pattern2>\|<patten2><pattern3>/d" <file_name>
14. If line contains the specific pattern, delete the line from file using sed command:
sed -i '/172.*/!d' netstat_20161230.log
15. To replace the file path with another file path using sed command:
sed -i 's#/srvrs/ag/asapprd1/#/u01/ag/asapprd1/ASAP/#g' /<file_name>
16. To replace the pattern with another pattern in a file using sed command:
sed -i "s/<pattern1>/<pattern2>/g" <file_name>
Comments
Post a Comment