Category: ubuntu
-
Unix – Count Requests Per Seconds From Access Log File
egrep “^14:59” access.log|grep exectime| sed ‘s/.*14:59.\(..\).*/\1/g’|sort |uniq -c|sort -n egrep “^14:” access.log|grep exectime| sed ‘s/.*14:\(…..\).*/\1/g’|sort |uniq -c|sort -n grep exectime access.log | awk ‘{print $1,$16,$7}’ > se1.log tail -f /var/logs/access.log|grep exectime | awk ‘{print $1,$16,$7}’ grep “job processed” res.log | awk ‘{ print $1″ “$2}’|sort -n|uniq -c|less Result: 6 2013-01-31 18:39:44 4 2013-01-31 18:39:45 34…
-
Virtualbox – How To Fix The Missing Menu bar on Ubuntu and Windows
The Virtualbox Menu bar disappears if the virtual machine is running in “scale mode”. Resizing the machine’s window: The virtual machine’s window can be resized when it is running. In that case, one of three things will happen: ” – If you have “scale mode” enabled, then the virtual machine’s screen will be scaled to the…
-
Unix – Extract multiple rar and zip files
Extract multiple zip files for z in *.zip; do unzip -f $z; done Extract multiple rar files for f in *.rar; do unrar -x $f; done unzip –help UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP. Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir] Default action is to extract files…
-
ffmpeg – Convert Adobe Flash FLV Files to MP4 Files
Simple Conversion of FLV to MP4 using FFMPEG ffmpeg chews the input buffers – use -nostdin flag to fix it find . -regextype posix-extended -iregex “.*.avi|.*.flv” -type f | while IFS= read -r file; do fn=”${file}”; echo “###$fn###”; dest=”${fn%.*}.mp4″; echo “###$dest###”; if [ -f “$dest” ];then rm “$dest”; fi; ffmpeg -nostdin -v 0 -i “$fn”…
-
Unix – grep, sort , uniq
Source File cat genre.txt ./014/735/54/00000000000001473554.xml ./014/735/10/00000000000001473510.xml ./014/726/18/00000000000001472618.xml ./014/726/26/00000000000001472626.xml ./014/726/08/00000000000001472608.xml ./014/726/42/00000000000001472642.xml grep Genre genre.txt |sed ‘s/.*Genre name=”\(.*\).>.*/\1/g’|sort|uniq –c grep Genre genre.txt |sed ‘s/.*Genre name=”\(.*\).>.*/\1/g’\ |sort|uniq -c|awk ‘{ print $2″\t”$1 }’|sort |sed ‘s/&apos//g’ grep Genre genre.txt |sed ‘s/.*Genre name=”\(.*\).>.*/\1/g’
-
Unix – Extract File Extension and Filename from Filepath
#file extension for f in *; do fn=”${f%.*}”;echo “fn=$fn,f=$f”; done;
-
Unix – tolower in bash, awk and sed
tr ‘[A-Z]’ ‘[a-z]’ # to lower case sed ‘s/]]/]/g’ # replace ]] with ] awk ‘{print tolower($0)}’ # change whole string to lower sed ‘s/^[0-9]*//g’ # replace all numbers with nothing
-
Unix – Seqential Remote Calls to Several Machines
Copy Data to multiple machines for i in 187 135; do echo “–server${i}–“; scp -p -r /dev/mydata myuser@myhost${i}.net:/dev ; done Execute Scripts in multiple machines Example 1 for i in 187 135; do echo “–server${i}–“; ssh myuser@myhost${i}.net “chmod 777 /dev/mydata.sh;rm -r /dev/main;” ; done Example 2 for i in 187 135; do echo “——de${i}——–“; ssh…
-
Postgres – Executing SQL-Statement in several remote machines sequentially
echo ‘psql -a -d mydatabase -p 5432 -c “\d mytable;”‘| ssh myuser@myserverhost.net ‘sudo su – postgres -c “bash -x — ” ‘ echo ‘psql -a -d mydatabase -p 5432 -c select id from mytable where id = 393050;”‘| ssh myuser@myserverhost.net ‘sudo su – postgres -c “bash -x — ” ‘
-
Unix – Check and Monitor Open Ports and established Connections
lsof -i lsof -i | less # firefox example lsof -i | grep firefox check every second while [ “1” ] ; do clear; lsof -i; sleep 1; done; # firefox example while [ “1” ] ; do clear; lsof -i | grep firefox; sleep 1; done; netstat |grep localhost while [ “1” ] ;…