I have a file with the following format:
123 2 3 48 85.64 85.95
Park ParkName Location
12 2.2 3.2 48 5.4 8.9
Now I could like to write a shell script to extract lines from this file. The first item from each line is a kind of flag. For different flags, I will make different process. See my code below:
head= ` echo "$line" | grep -P "^\d+" `
if [ "$head" != "" ]; then
(do something...)
fi
head=` echo "$line" | grep -P "^[A-Z]+" `
if [ "$head" != "" ]; then
(do something...)
fi
The code works. But I dislike the complicated way of writing 2 "if". I would like to have something simple like:
if [ "$head" != "" ]; then
(do something...)
elif [ "$head" != "" ]; then
(do something...)
fi
Any thoughts?
head= echo "$line" | grep -P "^\d+"work?