Hi,
I have record with three columns
ID TYPE Deal
01 A Member Since Year-2015
02 B Member Since Year-2014
03 A Member Since Year-2014
I only want year part from field Deal How to write a query?
Thanks,
Extract string from a column
Re: Extract string from a column
This isn't really a CentOS problem as such so I've moved it to the social forum for want of anywhere better to put it.
How are the columns separated?
How are the columns separated?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: Extract string from a column
$ awk -F- '{print $NF}' /path/to/fileKinjal wrote:Hi,
I have record with three columns
ID TYPE Deal
01 A Member Since Year-2015
02 B Member Since Year-2014
03 A Member Since Year-2014
I only want year part from field Deal How to write a query?
Thanks,
Just one way
Re: Extract string from a column
Another way:
Code: Select all
grep -Eo Year-[0-9]{4} /path/to/file |grep -Eo [0-9]{4}
Root is evil: Do not use root (sudo) to run any of the commands specified in my posts unless explicitly indicated. Please, provide the necessary amount of context to understand your problem/question.
Re: Extract string from a column
cut -d'-' -f 2- <file>
Re: Extract string from a column
sed 's!.*r-!!' /path/to/file