get rid of unwanted lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get rid of unwanted lines
# 1  
Old 08-09-2012
get rid of unwanted lines

Hi ,

My output contains the below contents

When i execute
Code:
 
df -h | grep / | grep -v '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }'

i get output as below

Code:
 
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/WebArch.vbs
                      1.7T  1.3T  452G  74% /vob/WebArch
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/Analyst_Metrics.vbs
                      1.7T  1.3T  452G  74% /vob/Analyst_Metrics
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/Analyst_Metrics_Admin.vbs
                      1.7T  1.3T  452G  74% /vob/Analyst_Metrics_Admin
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/ioscomp_tot.vbs
                      1.7T  1.3T  452G  74% /vob/ioscomp_tot
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/vob_etl_framework.vbs
                      1.7T  1.3T  452G  74% /vob_etl_framework
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/vob_pdsweb.vbs
                      1.7T  1.3T  452G  74% /vob_pdsweb
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/vob_nz_tick.vbs
                      1.7T  1.3T  452G  74% /vob_nz_tick
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/vob_rdrcore.vbs
                      1.7T  1.3T  452G  74% /vob_rdrcore
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/vob_sts_dashboard.vbs
                      1.7T  1.3T  452G  74% /vob_sts_dashboard
ghghg.fgh.com:/vol/scmvol1/fi-vobstore/vob_ewsmatlab.vbs
                      335G  259G   77G  78% /vob_ewsmatlab
ghghg.fgh.com:/vol/scmvol1/fi-vobstore/vob_fabricserver.vbs
                      335G  259G   77G  78% /vob_fabricserver
tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/vob_arrow2.vbs

now I would need to get rid of all the unnecessary lines like

ghghg.fgh.com:/vol/scmvol1/fi-vobstore/vob_ewsmatlab.vbs

tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/vob_sts_dashboard.vbs

any help on this pls.
# 2  
Old 08-09-2012
Code:
awk 'NF>1' filename

output is
Code:
                      1.7T  1.3T  452G  74% /vob/WebArch
                      1.7T  1.3T  452G  74% /vob/Analyst_Metrics
                      1.7T  1.3T  452G  74% /vob/Analyst_Metrics_Admin
                      1.7T  1.3T  452G  74% /vob/ioscomp_tot
                      1.7T  1.3T  452G  74% /vob_etl_framework
                      1.7T  1.3T  452G  74% /vob_pdsweb
                      1.7T  1.3T  452G  74% /vob_nz_tick
                      1.7T  1.3T  452G  74% /vob_rdrcore
                      1.7T  1.3T  452G  74% /vob_sts_dashboard
                      335G  259G   77G  78% /vob_ewsmatlab
                      335G  259G   77G  78% /vob_fabricserver

# 3  
Old 08-09-2012
Two piped grep commands is a resource waste. awk can filter on content. Give us a typical output of your dh command.
# 4  
Old 08-09-2012
Quote:
Originally Posted by ptappeta
Code:
 
df -h | grep / | grep -v '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }'

You might want to consider using the "-t" switch of df instead of grepping unwanted results afterwards. For instance:

Code:
df -h -t ext3 -t ext4

lists only the filesystems of type ext3 or ext4.

The switch "-P" will switch to a one-line-per-FS output format, which will probably easier to process too.

I hope this helps.

bakunin
# 5  
Old 08-09-2012
HI Thanks for the reply and it worked fine .
Would like to understand what it means actually that waht it did.
Code:
 
awk 'NF>1'

# 6  
Old 08-09-2012
Quote:
Originally Posted by ptappeta
HI Thanks for the reply and it worked fine .
Would like to understand what it means actually that waht it did.
Code:
 
awk 'NF>1'

Print the line if the number of fields > 1.
# 7  
Old 08-24-2012
hi my df -h is giving very much scrambled data .please see below .I dont want this kind of output .please advsie what can be done .
Code:
48% /
66M 30%
8.0G 0%
20% /opt
3% /tmp
86% /var
1% /var/crash
0% /fistrd01/fi/str/dv
16% /fmwrpd01/wrp
18% /usr/local/ifeeds
48% /view
86% /vobs/fi_etrading
86% /vobs/FI_EUD
86% /vobs/fi_pot
86% /vobs/fi_shared
86% /vobs/functors
86% /vobs/mm
86% /vobs/OnePoint
86% /vobs/pa
86% /vobs/play
86% /vobs/pnav
86% /vobs/qfw
86% /vobs/quant
86% /vobs/separate_accounts
86% /vobs/tools
86% /vobs/ude
86% /vobs/WebPOT
86% /vobs/Blob
86% /vobs/Repo
86% /vobs/Mist
86% /vobs/IssuerAppEditor
86% /vobs/CR_Approvals
86% /vobs/CR_SecurityDetail
86% /vobs/CR_Shared
86% /vobs/msigen
86% /vobs/ContentMgmt
86% /vobs/AMR
86% /vobs/fis_test
86% /vobs/SVQuery
86% /vobs/fis_release
86% /vobs/fi_basis_eda
86% /vobs/creditResearch
86% /vobs/IssuerWorkSpace
86% /vobs/FIDE
86% /vobs/fi_release
86% /vobs/fi_pot_eda
86% /vobs/FXTrading_arch2
86% /vob_fi_eda
86% /vob_fi_ead
86% /vob_fide_tst
86% /vob_ResearchPrint
86% /vob_quant_analysis
86% /vob_vinay_test
86% /vob_cbs

so /vob is repeatd so many times.but i want to only /vob.please advise
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Getting Rid of Annoying Bootstrap Table Borders and Wayward Table Lines

Bootstrap is great; but we have had some issues with Bootstrapped <tables> (and legacy <fieldset> elements) showing annoying, wayward lines. I solved that problem today with this simple jQuery in the footer: <script> $(function(){ $('tr, td, fieldset,... (0 Replies)
Discussion started by: Neo
0 Replies

2. Shell Programming and Scripting

For loop to get rid of first 2 lines(conditionally)

hello all, I get data from different vendors and need to clean it up. Usually it pretty straight forward when i have files that only have headers....but in my case i have files that have a starting line of file name(and some junk info) and 2nd line is headers and the 3rd line is were the actual... (11 Replies)
Discussion started by: crazy_max
11 Replies

3. Shell Programming and Scripting

awk prints unwanted new lines

Hello, I need a little help with the following: I'm using AWK to read input from a comma-seperated value file, and only printing certain fields like so: awk -F "," '{print $1,$3,$6}' /list.csv | tail -1 Which outputs the following: server1 APPID OS I run into a problem... (8 Replies)
Discussion started by: LinuxRacr
8 Replies

4. Shell Programming and Scripting

sed to get rid of unwanted characters

so i have strings such as this: 'postfix/local#2,5#|CRON.*12062.*root.*CMD#2,5#|roice.*NQN1#1,2#|toysprc#1,4#' i need to get rid of the "#" and the numbers between them for each of the strings above. so the desired output should be: ... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. Shell Programming and Scripting

Need to delete unwanted files!!!

Hi all, i am just a beginner in shell. Need some code for my problem. SCENARIO I have 2 directories. Let A,B. Everyday files from directory A are compressed and moved to B.(already got the script). In directory A abc.doc def.exe ghi.c jkl.pl In directory B abc.tar.gz... (1 Reply)
Discussion started by: debu182
1 Replies

6. Shell Programming and Scripting

grep out unwanted lines

Hi, I got a log file and I want to grep out a list of unwanted line which are IP's. Basiclly I want everything ecxept the ip's from my list. If I do a while read line do grep -v $ip_from_my_list logfile done <ip_list it just grep's one IP at a time and repeats. :( Thanks for... (3 Replies)
Discussion started by: stinkefisch
3 Replies

7. Shell Programming and Scripting

Remove unwanted lines

I have a .xml file, where i need some output. The xml file is like: Code: <?******?></ddddd><sssss>234</dfdffsdf><sdhjh>534</dfdfa>......... /Code I need the output like: code 234 534 . . . /code How can i do it? (5 Replies)
Discussion started by: anupdas
5 Replies

8. UNIX for Advanced & Expert Users

How to Remove the unwanted Blank Lines

I have a file with the below data, i would like to remove the end blank lines with no data. I used the below commands but could not able to succeed, could you please shed some light. Commands Used: sed '/^$/d' input.txt > output.txt grep -v '^$' input.txt > output.txt input.txt file... (5 Replies)
Discussion started by: Ariean
5 Replies

9. Shell Programming and Scripting

Get rid of first & last lines from STD_OUT

I have an application that executes, printing a bunch of text to the screen... only problem is that I don't want to see the first line (the internal command being run) or the last line (it says "done") is there something to chop off the first and last line simply through use of piping the... (2 Replies)
Discussion started by: jjinno
2 Replies

10. Shell Programming and Scripting

Filter unwanted lines

Hi All, I have the below input and i only want to filter out some un-wanted info from here. Expected output is below. Can somebody help ? The catch is that i want to grep those lines with term "k=" and lines with term "**" as the 1st column and "07" as the last column. And the number of... (15 Replies)
Discussion started by: Raynon
15 Replies
Login or Register to Ask a Question