Guest User

Untitled

a guest
Mar 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #!/bin/bash
  2. # This script will split the presstore list of tapes into a .CSV file with two seperate coloumns.
  3. file="$1"
  4. echo "Splitting tape list....."
  5. touch tempsplit.csv #creates temporary file for use later in script
  6. while IFs= read line
  7. do
  8. lastchar=$(echo $line | tail -c 2)
  9. if [ "$lastchar" == : ] #Ommits any lines that end with : else error
  10. then
  11. echo -ne
  12. elif [ "$lastchar" -ge 0 -a "$lastchar" -le 9 ] #Selects lines that end in number
  13. then
  14. breakdown=$(echo "$line" | cut -d':' -f2,6) #selects fileds 2 & 6 containing tape numbers
  15. master=$(echo "$breakdown" | cut -d'a' -f1) #cuts first number
  16. clone=$(echo "$breakdown" | cut -d':' -f2) #cuts second number
  17. final=$(echo -e "$master,$clone" | tr -d ' ' >> tempsplit.txt) #outputs to a temp csv file
  18. fi
  19. done < $file
  20. touch tapelist_split.csv
  21. awk 'NR % 2 == 0' tempsplit.txt | sort -n >> tapelist_split.csv #removes every 2nd line, sorts numerically, converts to a .CSV file
  22. rm -rf tempsplit.txt #removes tempfile
  23. echo "Complete"
  24.  
  25. grep '[0-9]$' "$file" | while IFS= read line; do
  26. ...
  27. done
  28.  
  29. if [ "$lastchar" == : ]
  30. then
  31. echo -ne
  32. elif ...
  33.  
  34. if ...; then
  35. :
  36. elif ...
  37.  
  38. if ! [ "$lastchar" -ge 0 -a "$lastchar" -le 9 ]; then
  39. continue
  40. fi
  41.  
  42. breakdown=...
  43.  
  44. breakdown=$(echo "$line" | cut -d':' -f2,6)
  45. master=$(echo "$breakdown" | cut -d'a' -f1)
  46. clone=$(echo "$breakdown" | cut -d':' -f2)
  47. final=$(echo -e "$master,$clone" | tr -d ' ' >> tempsplit.txt)
  48.  
  49. tape with barcode: 000053 and is: offline at listed location: MCR Shelves and is: Full and is copy of tape with barcode: 000047
  50. tape with barcode: 000044 and is: offline at listed location: MCR Shelves and is: Full and is copy of tape with barcode: 000042
  51.  
  52. grep '[0-9]$' file | head | sed -e 's/^[^0-9]*//' -e 's/[^0-9][^0-9]*/,/'
  53.  
  54. grep '[0-9]$' "$file" |
  55. sed -e 's/^[^0-9]*//' -e 's/[^0-9][^0-9]*/,/' |
  56. awk 'NR % 2 == 0' | sort -n > tapelist_split.csv
  57.  
  58. grep '[0-9]$' "$file" |
  59. sed -e 's/^[^0-9]*//' -e 's/[^0-9][^0-9]*/,/' -e '1~2d' |
  60. sort -n > tapelist_split.csv
  61.  
  62. while ...; do ...; done < "$file"
  63.  
  64. rm -rf tempsplit.txt
  65.  
  66. while IFs= read line
  67.  
  68. while IFS= read line
Add Comment
Please, Sign In to add comment