'echo *' I get the following output:
file1 file2 file3 ...
What I want is to pick out the first word. How can I proceed?
You can pipe it through awk and make it echo the first wird
or you cut the string up and select the first word:
or you pipe it thorugh sed and have it remove everything but the first word
Assuming that you really want the first filename and not the first word, here's a way that doesn't break on whitespace:
Assuming a posixy shell (
This solution assumes that the separator is a space. If you're doing this with file names then any with spaces will break it.