Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- SAVEDIFS=$IFS
- IFS=$(echo -en "\n\b")
- for elem in `find . -mindepth 1 -maxdepth 1 -type f`
- do
- if head -n 1 $elem | grep -q '^data:'
- then
- is_valid=true
- line_list=$(cat $elem | cut -d$'\n' -f2-)
- for line in $line_list
- do
- linecut=$(echo $line | cut -d "#" -f 1)
- if [[ ! -z "${linecut// }" ]]
- then
- if [[ ! $linecut =~ ^[on]:[0-9]{3}:[a-z]+:[0-9]+:[0-9]+$ ]]
- then
- is_valid=false
- fi
- fi
- done
- if [ "$is_valid" = true ]
- then
- echo $elem: | cut -d / -f 2 | tr [A-Z] [a-z]
- head -n 1 $elem
- for line in $line_list
- do
- linecut=$(echo $line | cut -d "#" -f 1)
- if [[ ! -z "${linecut// }" ]]
- then
- echo $linecut
- if [[ $linecut == o* ]]
- then
- echo $linecut >> o_lines
- fi
- if [[ $linecut == n* ]]
- then
- echo $linecut >> n_lines
- fi
- fi
- done
- fi
- fi
- done
- IFS=$SAVEDIFS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement