Artificial intelligent assistant

How to print empty spaces in first column using awk or sed Here is my sample input file. `ip.txt`: john math science paul math science rosy math jill science rob math science hary math Desired output: john paul rosy jill rob hary When I use: awk '{print $1}' ip.txt My output is: john science paul science rosy jill rob science hary I don not want the second column values printed, I want the blank spaces to be printed out to a file. How can I achieve this? I am using Solaris 5.10 with `ksh`.

awk:


awk '{print (NF>1) ? $1 : ""}' file


If the number of fields is more than 1, print the first field, otherwise print an empty line.

A couple of extra thoughts:

* If your data is tab-separated, then

awk -F '\t' '{print $1}' file


* If you want to extract the first 8 characters

awk '{print substr($0,1,8)}' file

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2094c4810f4e05309229bd019d925f94