Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

28.10.08

bash promt style customization

Nice documentation on how to change your prompt style.

My current one:

PS1='\[\033[1;33m\]\D{%H:%M} \[\033[1;39m\]\u \[\033[1;35m\]\w\[\033[0m\]: '

1.11.07

Bash scripts

Here i will try to post my "progress" in shell scripting i need for my work:

Read file contents and set it as a variables:

# test.txt
input_filename: /data/sat/l0.pds
start_time: 2007-10-20T09:27
stop_time: 2007-10-20T09:41


And solution, thanks to ghostdog74
#!/bin/bash
var=$(awk 'BEGIN{FS="[-:T]"}/start_time/{print $2,$3,$4}' "file")
set -- $var
YEAR=$1
MONTH=$2
DAY=$3
echo $YEAR $MONTH $DAY


double condition in "if" statement:

#!/bin/bash

min=10
max=25

for i in aapp.*.hrp
do
var=${i:9:2}
if [ "$var" -ge $min ] && [ "$var" -le $max ]
then
aapp -Y 2008 $i
fi
done
exit 0


Change day of year (that's not a julian day!) to a "normal" date

day=123
date -d "`date +%Y`-01-01 +$(( ${day} - 1 ))days" +%Y-%m-%d