cut -f 1-22 myfile.txt > mynewfile.txtThis made the file "mynewfile.txt" contain columns 1 to 22. You can also specify what kind of separator you want. If you don't choose any the program will assume TAB as the field separator.
Tuesday, May 25, 2010
About selecting a number of columns from a Text file
Today I had an interesting issue. I received a really big file with lots of columns in it. I only needed a few of them though, so I set out to write a quick Perl script to do the job, but then I thought to myself: "I'd better Google before I do this since it seems like a common enough problem.". Of course someone had already written a program like that. It's called cut and can be used from your terminal. I needed columns 1 to 22 from the file so I just issued
Labels:
column select,
cut,
linux,
text file,
ubuntu
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment