Im pretty stupid when in comes to bash and I was hoping someone could help me.
I would like to take the output of
hg resolve -l
which is in the format
R somefile/filename
U somefile/filename
R somefile/filename
U somefile/filename
and be able to use the first line that starts with a 'U' as an argument, so i could do things like
open -t <first U file>
and
hg resolve -m <first U file>
it would be great it someone could give me some pointers about the best way to do this!
Thanks
EDIT: solution from answers below, a simple script. Thanks guys!
#!/bin/bash
# Script that gets the first file from hg resolve | grep U and passes to default text editor
first_u_file=$(hg resolve -l | grep -m1 '^U')
first_u_file=${first_u_file#U }
echo opening \'$first_u_file\'
open -t "$first_u_file"
echo "opening '$first_u_file'"
- you don't need to escape the single quotes and the variable gets properly quoted. – Dennis Williamson May 31 '12 at 11:16