We have moved to www.dataGenX.net, Keep Learning with us.

Friday, January 30, 2015

Get nth character in a String in Linux


This is a  very popular Unix question, How to get 3rd char from a 3rd column of a tab delimited file ? We are usually know how to get the nth column by using "CUT" or "AWK" command. But not aware with this "CUT" options which can give the particular column. Lets see how to use this -


===================================================================================================================================
# To get 4th char from a string
echo 123456789 | cut -c4
# To get 7th char from a string
echo 123456789 | cut -c7
# To get 3rd and 4th char from a string
echo 123456789 | cut -c3,4
# To get 3rd char and so on from a string
echo 123456789 | cut -c3-


===================================================================================================================================


Like the Facebook Page & join Group
https://www.facebook.com/DataStage4you
https://www.facebook.com/groups/DataStage4you

https://twitter.com/datastage4you
https://groups.google.com/d/forum/datastage4you
For WHATSAPP group , drop a msg to 91-88-00-906098


No comments :

Post a Comment