IordanRujinov

Linux Practical Task 1

Jan 18th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.45 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. file="./current.tag.txt"
  4. date=$(date +%y.%m.%d)
  5.  
  6. if [ ! -e "$file" ]; then
  7.     touch current.tag.txt
  8.     tag=1
  9.     curr_tag=$(date +%y.%m.%d).$tag
  10.     echo $curr_tag > current.tag.txt   
  11. else
  12.     curr_tag=$(cat < current.tag.txt)
  13.     curr_date=${curr_tag:0:8}
  14.     tag=${curr_tag:9}
  15.     if [ $curr_date == $date ]; then
  16.         tag=$(($tag+1))
  17.     else
  18.         tag=1
  19.     fi
  20. fi
  21.  
  22. format_tag=`printf "%03d" $tag`
  23. echo $date.$tag > current.tag.txt
  24. echo $date.$format_tag
Advertisement
Add Comment
Please, Sign In to add comment