Monday, August 31, 2015

String Substring Linux

Suppose file "test" has strings with "-" separator. If you need to get the second part of the string into "test2" file, you can use the following command.

test
=======

90463619-15723905D.pdf
90465573-15728095D.pdf
91028582-16080834D.pdf

test2
=======
15723905D.pdf
16080834D.pdf
15728095D.pdf

cat test |awk -F"-" '{print $2}' > test2

No comments:

Post a Comment