Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat list.txt | grep '^http://.*.osm..*$' | while read line; do
- fn=$(basename $line)
- do_something()
- done
- # TODO: check if it did something
- if grep -q '^http://.*.osm..*$' list.txt # loop will definitely run
- then
- while read line
- do
- # do something with line
- done < <(grep '^http://.*.osm..*$' list.txt)
- else # no matches, loop will not run
- # do something else
- fi
- shopt -s lastpipe # bash 4.2 or greater only
- flag="false"
- cat list.txt | grep '^http://.*.osm..*$' | while read line; do
- fn=$(basename $line)
- do_something()
- flag="true"
- done
- if [ "$flag" = "true" ]
- then
- echo "loop was executed"
- fi
- while read line
- do
- fn=$(basename $line)
- do_something()
- flag="true"
- done < <(grep '^http://.*.osm..*$' list.txt)
- filtered=$(cat list.txt | grep ....)
- if [ -z "$filtered" ] ;
- ... handle empty output ..
- else
- ... do your while loop here...
- fi
- flag=0
- while read line; do
- flag=1
- fn=$(basename $line)
- do_something()
- done < <( grep '^http://.*.osm..*$' list.txt )
- if [[ $flag == 1 ]]; then
- ...
- fi
- flag=0
- while read line; do
- grep -q '^http://.*.osm..*$' <<< $line && {
- flag=1
- fn=$(basename $line)
- do_something()
- }
- done < list.text
- if [[ $flag == 1 ]]; then
- ...
- fi
Advertisement
Add Comment
Please, Sign In to add comment