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

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

am 18.04.2008 22:58:55 von wong_powah

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

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

am 18.04.2008 23:04:07 von cfajohnson

On 2008-04-18, wong_powah@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
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

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

am 19.04.2008 02:04:03 von G_r_a_n_t_

On Fri, 18 Apr 2008 13:58:55 -0700 (PDT), wong_powah@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@deltree:~$ cat inputfile
unix/ssh-host-keygen: echo "Generating 1024 bit SSH1 RSA host key

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

Grant.