1. Each line in a file:
for line in $(cat 2); do echo $line; done;
2. Sed
prefer to use '|' as delimiter if possible:
sed 's|my/home/directory||g' < in > out
in place replacement :
sed -i 's|analytics/etl/maxwell/src/assembly/hive/maxwell/||g' in
3. Sed replace \n to ,\n
sed ':a;N;$!ba;s/\n/,\n/g'
4. sort by column
sort -t "," -k 2 -n input.csv
sorted by column 2
5. bash loop in number
for i in $(seq 0 855)
do
date=$(date --date "$i day ago" "+%Y%m%d")
echo "alter table oauth_user_services add if not exists partition (dt = '$date') location '$date';" >> partitions
done
No comments:
Post a Comment