Category Archives: bash

Split and join files

How to split a file in chunks and how to put them back together.

 bash | 
 
 copy code |
?

01
### SPLIT LONG:
02
split --bytes=5m --suffix-length=2 --numeric-suffixes image.iso image.iso.part_
03
split --verbose --bytes=5m --suffix-length=2 --numeric-suffixes image.iso image.iso.part_
04
05
06
### SPLIT SHORT:
07
split -b 5m -a 2 -d image.iso image.iso.part_
08
09
10
split --verbose -b 5m -a 2 -d image.iso image.iso.part_
11

HTTP Proxy Checker in bash

Usefull script  to check if a proxy is alive.

02
### RESTORE
03
cat image.iso.part_* > image.iso
04
05
 bash | 
 
 copy code |
?

01
#!/bin/bash
06
# HTTP Proxy Server's IP Address (or URL)
07
08
proxy_server=$1
09
10
# HTTP Proxy Server's Port Number
11
12
port=$2
13
14
15
# We're trying to reach this url via the given HTTP Proxy Server
16
# (http://www.google.com by default)
17
18
url="http://www.google.com"
19
20
# Timeout time (in seconds)
21
timeout=20
22
23
# We're fetching the return code and assigning it to the $result variable
24
result=`HEAD -d -p http://$proxy_server:$port -t $timeout $url`
25
26

Google URL shortener script

Maybe it’s no longer working

# If the return code is 200, we've reached to $url successfully
02
if [ "$result" = "200 OK" ]; then
03
    echo "1 (proxy works)"
04
# Otherwise, we've got a problem (either the HTTP Proxy Server does not work
05
06
# or the request timed out)
07
else
08
    echo "0 (proxy does not work or request timed out)"
09
10
fi
11
 bash | 
 
 copy code |
?

01
#!/bin/bash
12
# Google url shortener bash script
13
# We're fetching the return code and assigning it to the $result variable
14
# http://ggl-shortener.appspot.com/instructions/
15
16
app='http://ggl-shortener.appspot.com/?url='
17
url="$1"
18
protocol=`echo "$1" | sed -e "/^http:///g"`
19
20
if [ -z "$1" ]; then
21