Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This script will split the presstore list of tapes into a .CSV file with two seperate coloumns.
- file="$1"
- echo "Splitting tape list....."
- touch tempsplit.csv #creates temporary file for use later in script
- while IFs= read line
- do
- lastchar=$(echo $line | tail -c 2)
- if [ "$lastchar" == : ] #Ommits any lines that end with : else error
- then
- echo -ne
- elif [ "$lastchar" -ge 0 -a "$lastchar" -le 9 ] #Selects lines that end in number
- then
- breakdown=$(echo "$line" | cut -d':' -f2,6) #selects fileds 2 & 6 containing tape numbers
- master=$(echo "$breakdown" | cut -d'a' -f1) #cuts first number
- clone=$(echo "$breakdown" | cut -d':' -f2) #cuts second number
- final=$(echo -e "$master,$clone" | tr -d ' ' >> tempsplit.txt) #outputs to a temp csv file
- fi
- done < $file
- touch tapelist_split.csv
- awk 'NR % 2 == 0' tempsplit.txt | sort -n >> tapelist_split.csv #removes every 2nd line, sorts numerically, converts to a .CSV file
- rm -rf tempsplit.txt #removes tempfile
- echo "Complete"
- grep '[0-9]$' "$file" | while IFS= read line; do
- ...
- done
- if [ "$lastchar" == : ]
- then
- echo -ne
- elif ...
- if ...; then
- :
- elif ...
- if ! [ "$lastchar" -ge 0 -a "$lastchar" -le 9 ]; then
- continue
- fi
- breakdown=...
- breakdown=$(echo "$line" | cut -d':' -f2,6)
- master=$(echo "$breakdown" | cut -d'a' -f1)
- clone=$(echo "$breakdown" | cut -d':' -f2)
- final=$(echo -e "$master,$clone" | tr -d ' ' >> tempsplit.txt)
- tape with barcode: 000053 and is: offline at listed location: MCR Shelves and is: Full and is copy of tape with barcode: 000047
- tape with barcode: 000044 and is: offline at listed location: MCR Shelves and is: Full and is copy of tape with barcode: 000042
- grep '[0-9]$' file | head | sed -e 's/^[^0-9]*//' -e 's/[^0-9][^0-9]*/,/'
- grep '[0-9]$' "$file" |
- sed -e 's/^[^0-9]*//' -e 's/[^0-9][^0-9]*/,/' |
- awk 'NR % 2 == 0' | sort -n > tapelist_split.csv
- grep '[0-9]$' "$file" |
- sed -e 's/^[^0-9]*//' -e 's/[^0-9][^0-9]*/,/' -e '1~2d' |
- sort -n > tapelist_split.csv
- while ...; do ...; done < "$file"
- rm -rf tempsplit.txt
- while IFs= read line
- while IFS= read line
Add Comment
Please, Sign In to add comment