Printing multiple columns from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Printing multiple columns from a file
# 1  
Old 05-02-2013
Printing multiple columns from a file

Hi,
I need just to print the values of second and fourth column from a file
Code:
# cat dispaly
id Name Std Specialist
1  sss  X   mathematics
2  uyt  IX  geography
3  vcd  X   English

i tried with some NF command.. I think am wrong.. Is there anyother way to print my requirement
# 2  
Old 05-02-2013
Why go for NF when you have the columns fixed??

Code:
awk '{ print $2, $4}' file

This User Gave Thanks to PikK45 For This Post:
# 3  
Old 05-02-2013
It worked.. Thanks Smilie
# 4  
Old 05-02-2013
From next time, please show us what you tried too Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing every alternate columns in a text file

Hi, I have a big matrix with 1 million columns and 21 rows, which is a tab delimited file. I would like to print every alternate columns into a new file. For each row, the start column will be always the first column. For example the input file 1 2 4 5 8 0 7 9 2 5 6 3 0 6 9 2 3 6 3 6 6 0... (3 Replies)
Discussion started by: Kanja
3 Replies

2. Shell Programming and Scripting

Compare Multiple Columns in one file

Hello guys, I am quite new to Shell Scripting and I need help for this I have a CSV file like this: Requisition,Order,RequisitionLineNumber,OrderLineNumber REQ1,Order1,1,1 REQ1,Order1,1,3 REQ2,Order2,1,5 Basically what I want to do is compare the first 3 fields If all 3 fields are the same... (5 Replies)
Discussion started by: jeffreybsu
5 Replies

3. Shell Programming and Scripting

Shell scripting - need to arrange the columns from multiple file into a single file

Hi friends please help me on below, i have 5 files like below file1 is x 10 y 20 z 15 file2 is x 100 z 245 file3 is y 78 z 23 file4 is x 100 (3 Replies)
Discussion started by: siva kumar
3 Replies

4. Shell Programming and Scripting

How do I parse file with multiple different columns ?

I have a tool which generates results in a file at every minute and which has following columns. I need to create a script checks this file constantly and if Column ( QOM ) has value more then "30S" it should send an email. Can anybody help ? Thansk a lot. Time MxML MxQD G P OIC OUC MDC... (11 Replies)
Discussion started by: jayeshpatel
11 Replies

5. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

6. Shell Programming and Scripting

Trouble printing multiple lines to a new file

Hi, I'm trying to auto generate some php files with a default preamble at the top which is a block comment. The problem is that my output has no new lines and it looks like the output from "ls" is being printed after everyline This is my code #!/bin/bash read -d '' pre_amble... (1 Reply)
Discussion started by: racshot65
1 Replies

7. UNIX for Dummies Questions & Answers

Comparing the 2nd column in two different files and printing corresponding 9th columns in new file

Dear Gurus, I am very new to UNIX. I appreciate your help to manage my files. I have 16 files with equal number of columns in it. Each file has 9 columns separated by space. I need to compare the values in the second column of first file and obtain the corresponding value in the 9th column... (12 Replies)
Discussion started by: Unilearn
12 Replies

8. Shell Programming and Scripting

Perl, searching multiple files and printing returned line to new file

I am trying to find a way to utilise the full potential of my cpu cores and memory on my windows machine. Now, I am quite familiar with grep, however, running a Unix based OS is not an option right now. Unfortunately, the 32 bit grep for windows that I am running, I cannot run multiple... (1 Reply)
Discussion started by: Moloch
1 Replies

9. Shell Programming and Scripting

Comparing Columns and printing the difference from a particular file

Gurus, I have one file which is having multiple columns and also this file is not always contain the exact columns; sometimes it contains 5 columns or 12 columns. Now, I need to find the difference from that particular file. Here is the sample file: param1 | 10 | 20 | 30 | param2 | 10 |... (6 Replies)
Discussion started by: buzzusa
6 Replies

10. UNIX for Dummies Questions & Answers

sorting a file with multiple columns

I have a file with several columns: Column1 Column2 Column3. . .Column6 I want to sort the data from Column6. Could I do that through sort even if there are spaces in between fields? Much thanks! outta. (3 Replies)
Discussion started by: outtacontrol
3 Replies
Login or Register to Ask a Question