parse a text file and extract everything before the ':' char

How to parse a text file and extract everything before the ':' char?

e.g. input text file is:
unix/ssh-host-keygen: echo "Generating 1024 bit SSH1 RSA host key

Output should be:
unix/ssh-host-keygen
wong_powah [ Fr, 18 April 2008 22:58 ] [ ID #1945051 ]

Re: parse a text file and extract everything before the ':' char

On 2008-04-18, wong_powah [at] yahoo.ca wrote:
> How to parse a text file and extract everything before the ':' char?
>
> e.g. input text file is:
> unix/ssh-host-keygen: echo "Generating 1024 bit SSH1 RSA host key
>
> Output should be:
> unix/ssh-host-keygen

cut -d: -f1 TEXTFILE

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
cfajohnson [ Fr, 18 April 2008 23:04 ] [ ID #1945052 ]

Re: parse a text file and extract everything before the ':' char

On Fri, 18 Apr 2008 13:58:55 -0700 (PDT), wong_powah [at] yahoo.ca wrote:

>How to parse a text file and extract everything before the ':' char?
>
>e.g. input text file is:
>unix/ssh-host-keygen: echo "Generating 1024 bit SSH1 RSA host key
>
>Output should be:
>unix/ssh-host-keygen

grant [at] deltree:~$ cat inputfile
unix/ssh-host-keygen: echo "Generating 1024 bit SSH1 RSA host key

grant [at] deltree:~$ awk -F: '{print $1; exit}' inputfile
unix/ssh-host-keygen

Grant.
G_r_a_n_t_ [ Sa, 19 April 2008 02:04 ] [ ID #1945590 ]
Linux » comp.unix.shell » parse a text file and extract everything before the ':' char

Vorheriges Thema: bash: best way to do tenary operator??
Nächstes Thema: let built-in doesn't work as expected