![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding a new column in a text file | snahata | Shell Programming and Scripting | 10 | 03-13-2009 07:00 AM |
| Filtering records of a file based on a value of a column | risk_sly | UNIX for Dummies Questions & Answers | 4 | 09-24-2008 03:22 AM |
| Adding specific text and spaces to each line in a text file | hertingm | Shell Programming and Scripting | 4 | 08-25-2008 03:34 PM |
| FILE:Adding new column | sandeep_hi | Shell Programming and Scripting | 2 | 06-09-2006 10:46 AM |
| Changing the column for a row in a text file and adding another row | aYankeeFan | Shell Programming and Scripting | 9 | 05-02-2005 10:42 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Adding a column to a text based on file name
Dear all,
Does anyone know how I could to add a column of numbers (1s, or 2s, or..., or 6s) to two-column text files (tab-delimited), where the specific number to be added varies as a function of the file naming? Currently, each of my text files has two columns, so the column with the repeated number in it would be the third column. The groups of six text files are located within separate directories, and the easiest way to get at their naming (which determines which number should be added) is by using "ls" - it will always list them in the right order, such that first text file listed should have a third column added with "1s" (for as many rows as it has; where the number of rows varies depending on the specific text file); and the second text file listed should have a third column appended with "2s", so on and so forth. I am still quite new to programming, and my intuition tells me I should use the command "ls" and then pipe "|" that to a certain command that would execute "if the file is the first one, add a column of ones, if file is the second one, a column of twos..." etc. Thank you so much for any feedback! Regina |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|