I have a .csv file with about 8k columns, 12 rows per column. The second row is in this format: ' name /id ' and I need it to only have the name part. What is the easiest way to remove everything after the / in the rows?
            Asked
            
        
        
            Active
            
        
            Viewed 81 times
        
    -2
            
            
        - 
                    I would recommend you to transpose the table, then you can use awk to do your replacement very easily. http://stackoverflow.com/questions/1729824/transpose-a-file-in-bash – Javier Castellanos Feb 16 '15 at 20:03
 - 
                    2post some small, representative, sample input with the associated desired output, otherwise we're just guessing at your requirements. – Ed Morton Feb 16 '15 at 21:37
 - 
                    each column is separated by a space?? – repzero Feb 17 '15 at 00:01
 
2 Answers
0
            
            
        If I get it correctly, you might want to modify every 12th row in a file? You might try:
awk 'NR % 12 == 0 {print gensub("/.*$","",$0) ; next}
     {print}' INPUTFILE
        Zsolt Botykai
        
- 50,406
 - 14
 - 85
 - 110
 
0
            
            
        This may do:
awk -F, '{sub(/\/.*/,"",$2)}1' OFS=, file
Example:
echo "test,paul/22,more" | awk -F, '{sub(/\/.*/,"",$2)}1' OFS=,
test,paul,more
        Jotne
        
- 40,548
 - 12
 - 51
 - 55
 
- 
                    When I try this, it only removed the /id part on the first line, after which the 5th row gets combined with the second column so that there is loss of information. Also, all other /id parts are still attached. This is a .csv file generated from Excel if that makes any difference... – ahetman Feb 17 '15 at 15:42
 -