Note, bash isn't known for its blinding speed handling large files, but as long as the column list isn't horrendously long, the script should be reasonably fast. Give it a try and let me know if you have any questions. But one thing at a time.) $ printf '%s\n' colname_"Įxample Use/Output $ bash colnum.sh dat/col data.txt dat/col.txt (You can always convert a tab-separated line of column headings to this format we're going to do just that with the data file's column headings. You can actually do this by keeping track of the array indexes for the columns that match the column names in your file containing the column list. So let's see how to use a few standard utilities - grep, tr, cut and paste - to achieve this goal.įor simplicity, let's put the desired column headings into a file, one per line. You can write loops which read each line in a massive file, but it's painfully slow because bash is not optimized for speed. Bash works best as "glue" between standard command-line utilities.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |