[Solved] Slight variation from the desired results


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Slight variation from the desired results
# 1  
Old 12-18-2012
[Solved] Slight variation from the desired results

Hello,

I am writing a small one liner script to display the tables in my database.
I am working with Centos 5.5 and postgresql

the command is
"
Code:
psql -c "\dt" | awk '{print$3}'

"

I just want the 3rd column from the result set, but now the problem is I am getting the third column but with the header of \dt information.
i.e. The results I am getting is

Code:
Relation
names

actor
employee
staff
film
film-category
payment

Instead of this result, I want some thing like this.

Code:
actor
employee
staff
film
film-category
payment

The first two lines should be eliminated.
I tried using the grep -A command but didn't work.
Please suggest.

Last edited by Scrutinizer; 12-18-2012 at 06:22 AM.. Reason: code tags
# 2  
Old 12-18-2012
Just check how many lines of your message has header files.

Assume it first two lines are header file here.. use

Code:
 "psql -c "\dt" | awk 'NR>2{print$3}'"

This User Gave Thanks to pamu For This Post:
# 3  
Old 12-18-2012
From what we can see in the desired output, it should start with line 4, so pamu's proposal should be slightly modified to using NR>3.
This User Gave Thanks to RudiC For This Post:
# 4  
Old 12-19-2012
It worked just fine and perfect for me.
Thanks pamu and Rudic.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Shell script output in HTML or with table like results and mail

Hello, Currently i have a script which will disply the results in plain text format. I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html and send that content as email. Please help me how i can do that. I am using... (10 Replies)
Discussion started by: joy lobo
10 Replies

2. Shell Programming and Scripting

awk variation question

I have a file like this: ASSPASVFETQY,hTRBV12-4,hTRBJ2-5,2 ASSPASTGGDYGYT,hTRBV18,hTRBJ1-2,2 ASSPASGDGYT,hTRBV5-1,hTRBJ1-2,2 ASSPASFPEDTQY,hTRBV27,hTRBJ2-3,2 ASSPARVNYGYT,hTRBV5-1,hTRBJ1-2,2 ASSPARTSGGLNEQF,hTRBV6-4,hTRBJ2-1,2 ASSPARQSYNEQF,hTRBV11-1,hTRBJ2-1,2... (4 Replies)
Discussion started by: xshang
4 Replies

3. UNIX for Dummies Questions & Answers

scp shows size variation

Hi i have folder of 26 GB on server A and want to copy to server B .i used the below commands to check file size and scp copy du -h /folder : its shows 26G on server A from server B: scp -r user@serverA:/folder/* ./copying got initiated and i am checking the file size on server B... (7 Replies)
Discussion started by: rakeshkumar
7 Replies

4. Shell Programming and Scripting

Sed in vi - \r and \n not giving desired results

I use many different machines at work, each with different versions of o/s's and installed applications. Sed in vi is particularly inconvenient in the sense that sometimes it will accept the "\r" as a carriage return, sometimes not. Same thing with "\n". For instance, if I have a list of hosts... (7 Replies)
Discussion started by: MaindotC
7 Replies

5. Linux

Slight Linux Upgrade

Hello Ya'all: I hope Zaxxon is still around. I read a posting about compiling/updating the kernel from source. I'm doing a very specific upgrade, and am wondering if there is anything different or if there's an easy way to do this: I am using kernel version 2.6.18-92, and have done some... (1 Reply)
Discussion started by: Statue
1 Replies

6. Shell Programming and Scripting

HELP: I need to sort a text file in an uncommon manner, can't get desired results

Hi All I have a flat text file. Each line in it contains a "/full path/filename". The last three columns are predictable, but directory depth of each line varies. I want to sort on the last three columns, starting from the last, 2nd last and 3rd last. In that order. The last three columns... (6 Replies)
Discussion started by: JakeKatz
6 Replies

7. UNIX for Dummies Questions & Answers

top's USER column width variation

hello, does anyone know how to expand the column width so it could contain full USER cell and not cut it in top ? Now it has eleven symbols but I can see only eight actualy I found only PID, PPID and %CPU columns variation possibilities in changelog (procps v.3.2.5). thanks in advance. (1 Reply)
Discussion started by: bugs_moran
1 Replies

8. UNIX for Dummies Questions & Answers

performance variation between two commands

does it make any difference in terms of performance while using any of the below mentioned code for the same requirement which processes continuously coming files in the I/P directory . Please provide ur viewws ls -tr $SAPRESPONSEGOFILE | sed "s/go/dat/g" | while read SAPRESPONSEFILES... (3 Replies)
Discussion started by: praviper
3 Replies

9. Shell Programming and Scripting

egrep not giving desired results

I have written a shell script which looks like below: grep -v ',0,' ./DATA/abc.001 > ./DATA/abc.mid egrep $GREPSEARCH ./DATA/ebc.mid > ./DATA/abc.cut the variable GREPSEARCH has values like the below: ... (3 Replies)
Discussion started by: igandu
3 Replies

10. UNIX for Dummies Questions & Answers

Having a slight problem!?

having a slight problem. any clues would help. Can't seem to get any output when I run a simple echo script. grex.cyberspace.org% chmod a+x test grex.cyberspace.org% ls -l test -rwxrwx--x 1 gordybh cohorts 20 Dec 13 20:22 test grex.cyberspace.org% cat test #!/bin/sh echo test... (2 Replies)
Discussion started by: wmosley2
2 Replies
Login or Register to Ask a Question