Read a text file in bash line by line with while. It will read till the end of line. You can modify the end of line setting a new value to EOF variable.
while read line; do echo "${line}"; done < <(cat file.lst)
Read a text file in bash line by line with while. It will read till the end of line. You can modify the end of line setting a new value to EOF variable.
while read line; do echo "${line}"; done < <(cat file.lst)
Easiest way to clone a partition in command line.
dd if=/dev/sda1 of=/dev/sdb1
Recursively search all files matching a regexp in the current directory and then listing them.
find . -type f -name "*.file" | xargs grep -l "STRING"
This could also be done like this:
find . -type f -name "*.file" --exec grep -l "STRING" {} \;
This is a recursive description. Watch if a page changes with watch.
watch -d -n 5 "echo `date` `wget --timeout=5 -qO - URL
If you notice high load in your server or unresponsive services it might be you are suffering an ddos attack. If you want to have one snapshot of ips connected to your server, just type this command:
$ netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
Easy easy. Just like this. Dont forget to down/up the interface
#sudo ifconfig eth0 down hw ether 11:22:33:44:55:66
#sudo ifconfig eth0 up
Don’t use it as a way to count visits, as all these ips are not real visits, but bots, crawlers, etc.
cat access.log | grep -o '\([0-9]\{23\}.\)\{3\}\.[0-9]\{23\}' | sort | uniq | wc -l
If typing ifconfig is too simple for you here it is the geeky way to get the ip of your interfaces.
ifconfig | sed -n "/en0//netmask/ p" | grep "inet " | awk '{print$2}' copy to .bash_profile:
alias getip='ifconfig | sed -n "/en0//netmask/ p" | grep "inet " | awk ''{print\$2}'''
How to extract a tar file to a directory
tar -cvvf archive.tar /pathtoextract
Here’s the trick:
cat /tmp/test | awk 'NF > 0' > /tmp/test1