Command combination for displaying header and content


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Command combination for displaying header and content
# 1  
Old 08-19-2014
Command combination for displaying header and content

Hi everyone,
I have UNIX this semester and I am just getting started with the commands. An interesting question came up while discussing the head and tail commands.

Suppose that I have text file with the following data in the following format-:

Code:
NAME ROLL MARKS
Sam  05      80
John 06      90
Mark 07      90

Columns are separated with just one space. That means that there is only one space separating name from roll and one space separating roll from marks.

What I want to do sounds simple enough I want to print the details of JOHN only ALONG with the header information.

That means that NAME ROLL MARKS along with the record of John after it.

How do I do this with a combination of commands ? Or how is possible with the head and tail commands to be more precise ?

I have tried the following-:

Code:
head -1 a.txt | tee /dev/tty | tail

(a.txt is the name of the file in my system containing the above entries)
but this does not work and the reason is that after running the head command I get only one line and that is printed (which will be header since it is the first line). But I am unable to get the header and the particular record.

Is there someway I can filter within the tee command ?

Thanks.
# 2  
Old 08-19-2014
Hello,

Could you please read the forum guidlines and post this query in Home work/assigment forum by following all forum rules.


Thanks,
R. Singh
# 3  
Old 08-19-2014
Quote:
Originally Posted by RavinderSingh13
Hello,

Could you please read the forum guidlines and post this query in Home work/assigment forum by following all forum rules.


Thanks,
R. Singh
Well I have done what you have said here is the link to the new thread created in the Homeworks forums-:
Command combination for displaying header and content

I just hope someone replies ASAP.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Content of attachment is displaying along with subject in mailx

Hi All, I want to send the csv to an email address. I have tried the below two approaches. Approach1: Got error -ksh: uuencode: not found $ uuencode test_file.csv test_file.csv | mailx -s "Attaching test" msdc.kiran@gmail.com </usr/home/test_file.csv -ksh: uuencode: not found Approach2:... (6 Replies)
Discussion started by: ROCK_PLSQL
6 Replies

2. Shell Programming and Scripting

Problem while displaying(cat) file content inside telnet loop .

Hi Team, Not getting the file output inside my email which i am sending from unix box. . Please refer the below code : #!/bin/sh { sleep 5 echo ehlo 10.56.185.13 sleep 3 echo mail from: oraairtel@CNDBMUREAPZP02.localdomain sleep 3 echo rcpt to: saurabhtripathi@anniksystems.com... (1 Reply)
Discussion started by: tripathi1990
1 Replies

3. Shell Programming and Scripting

Displaying Column header in shell script

Hi, I need to display specific columns using select statement and spooled to a file and sending it as e-mail. But i am not seeing column header in my output even i use SET HEADING ON.//PREDEFINED LOGIN DETAILS ${ORACLE_HOME}/bin/sqlplus -s ${DB_LOGIN}/${DB_PASSWD} <<EOF SET FEEDBACK OFF SET... (1 Reply)
Discussion started by: pvelmuru
1 Replies

4. UNIX for Dummies Questions & Answers

Crunch character combination and discard similar content

Hi guys ! I generated the power set of the set S={a,b,c} using crunch: crunch 1 3 abc and get the 39 possible subsets: a b c aa ab ac ba bb bc ca cb cc … (2 Replies)
Discussion started by: beca123456
2 Replies

5. Homework & Coursework Questions

Command combination for displaying header and content

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: You are given a ANSI text file (a.txt) in the following format and with the following contents-: NAME ROLL... (7 Replies)
Discussion started by: sreyan32
7 Replies

6. Shell Programming and Scripting

Print the column content based on the header

i have a input of csv file as below but the sequence of column get changed. I,e it is not necessary that name comes first then age and rest all, it may vary. name,age,marks,roll,section kevin,25,80,456,A Satch,23,56,789,B Meena,24,78,H245,C So i want to print that column entires which... (12 Replies)
Discussion started by: millan
12 Replies

7. Homework & Coursework Questions

Linux displaying content information

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Using the fixed length field file called famous.dat make a one-line Unix command - using pipe(s) - to display an... (5 Replies)
Discussion started by: wizardoz123456
5 Replies

8. UNIX for Dummies Questions & Answers

Banner not displaying full content

HI, while using banner command, i am not getting the full content in the screen: banner "UNIX AUTOMATION" # # # # ### # # # # # ####### ####### # # # # ## # # # # # # # # # # # ## ## # # # # # # ... (5 Replies)
Discussion started by: pandeesh
5 Replies

9. Shell Programming and Scripting

Help with rename header content based on reference file problem

I got long list of reference file >data_tmp_number_22 >data_tmp_number_12 >data_tmp_number_20 . . Input file: >sample_data_1 Math, 5, USA, tmp SDFEWRWERWERWRWER FSFDSFSDFSDGSDGSD >sample_data_2 Math, 15, UK, tmp FDSFSDFF >sample_data_3 Math, 50, USA, tmp ARQERREQR . . Desired... (7 Replies)
Discussion started by: perl_beginner
7 Replies

10. Shell Programming and Scripting

Extract specific content from data and rename its header problem asking

Input file 1: >pattern_5 GAATTCGTTCATGTAGGTTGASDASFGDSGRTYRYGHDGSDFGSDGGDSGSDGSDFGSDF ATTTAATTATGATTCATACGTCATATGTTATTATTCAATCGTATAAAATTATGTGACCTT SDFSDGSDFKSDAFLKJASLFJASKLFSJAKJFHASJKFHASJKFHASJKFHSJAKFHAW >pattern_1 AAGTCTTAAGATATCACCGTCGATTAGGTTTATACAGCTTTTGTGTTATTTAAATTTGAC... (10 Replies)
Discussion started by: patrick87
10 Replies
Login or Register to Ask a Question