Want to separate one column


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Want to separate one column
# 1  
Old 07-10-2013
[Solved] Want to separate one column

I have one command which provide following output related to file system and disk space utilization
Code:
Filesystem     kbytes      used          avail              %used        Mounted on
/dev/lvol3     131072   73407    54088        58%               /
/abc/lvol1      59797    30314     2350300        56%         /stand
/xyz/lvol     614400   199806   390584     34%               /var
/pri/lvol     614400   478211    127690     79%                 /usr
/sol/lvol     518285    64668     401788      100%              /tmp


I want to separate only %used column. Output should be like
Code:
58%
56%
43%
79%
100%

Can anyone help.?
There is no wel defined separator for this table. So we can not use cut command. Is there any alternate way.?

Last edited by Franklin52; 07-10-2013 at 08:31 AM.. Reason: Please use code tags
# 2  
Old 07-10-2013
Hello,

Please use following command.


Code:
 
df | grep -v "used" |  awk '{print$3}'

I have removed used into the Output as I haven't seen it in requirement.




Thanks,
R. Singh
# 3  
Old 07-10-2013
Quote:
Originally Posted by RavinderSingh13
Hello,

Please use following command.


Code:
 
df | grep -v "used" |  awk '{print $3}'

I have removed used into the Output as I haven't seen it in requirement.




Thanks,
R. Singh
It should be $5
# 4  
Old 07-10-2013
it should be

Code:
 
df|awk 'NR>1{print $5}'

# 5  
Old 07-10-2013
None of the above command is working. Smilie
Is there any way to separate the % sign and its previous 3 characters from whole output.
I mean can we use % symbol as an identifier character for this problem. ?
The original command that i use to get this output is
Code:
 bdf

instead of
Code:
df

# 6  
Old 07-10-2013
the one give by vidyadhar85 will work if you type bdf instead of df ...
Code:
bdf|awk 'NR>1{print $5}'

Next time mention your OS (Here HP-UX...)
Code:
ant:/home/vbe $ bdf|awk 'NR>1{print $5}'|more
51%
47%
70%
16%
93%
51%
75%
17%
20%
78%
84%
40%
53%
96%
68%
75%
82%
98%
63%
89%
76%
54%
55%
77%


Last edited by vbe; 07-10-2013 at 10:20 AM.. Reason: added hpux output
# 7  
Old 07-10-2013
Thanks.. This above command works.. However there is one more issue..

The output of
Code:
bdf

is sometimes as below.

Filesystem kbytes used avail %used Mounted on
/dev/lvol1 2057629 685564 1166302 37% /bto
/dev/abc/lvol5 327680 128567 186825 41% /bto/sys/tng
cfb1n1-rep.slc.pri.com:/vol/v39_fs01_common/q00_fs01_common/
629145600 265905260 363240340 42% /nas/common

Now in this case the output of your command
Code:
  bdf|awk 'NR>1{print $5}'|more

is like

37%
41%

/nas/common

So it is not giving 42%. Instead of that it is giving /nas/common.
Can we have solution for this problem.?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to separate data coming in one column of CSV file?

I am running an ISQL command on Sybase DB and getting output of a query in an CSV file. The issue is that all the data comes in to the same column, i want them to be separated in different columns. SQL_COMMAND=command.sql file=file.txt formatFile=formatFile.txt report=report.csv echo... (1 Reply)
Discussion started by: Sharma331
1 Replies

2. Shell Programming and Scripting

How to separate rows of data into another column?

I have data such as below where the value in second field is the same as that in the row after. 123456,22222,John,0,xyz 234567,22222,John1,1,cde 43212,3333,Jean,3,pip 84324,3333,Abel,2,cat I'd like to rearrange the output like below to put such records beside each other and separated with... (5 Replies)
Discussion started by: james2009
5 Replies

3. Shell Programming and Scripting

How to parse parts of 1 column into two separate columns?

I have a shell script that is currently transferring a csv file from a server into a Teradata database table. One of the 30 or so columns is called "destination_url". In that URL there are parameters, and it is possible for those parameters to be repeated because of referring companies copying... (3 Replies)
Discussion started by: craigwg
3 Replies

4. Shell Programming and Scripting

Splitting a column in two separate fields

for making a summary I have a CSV file which is transformed to .DAT. I have an AWK file which is supposing to do the mapping of the DAT file. The code from the AWK file is the one below. The content of the DAT file looks like this (tab separated): ODT AGE CDT CO SEX TIME VALUE COMMENT ... (1 Reply)
Discussion started by: grikoss
1 Replies

5. Shell Programming and Scripting

Match first column and separate entries

Hi I have 2 big files containing following information: file 1 12345 345634 217341 87234693 8236493 file 2: 12345 1237 (6 Replies)
Discussion started by: kaav06
6 Replies

6. Shell Programming and Scripting

Print every 5 4th column values as separate row with different first column

Hi, I have the following file, chr1 100 200 20 chr1 201 300 22 chr1 220 345 23 chr1 230 456 33.5 chr1 243 567 90 chr1 345 600 20 chr1 430 619 21.78 chr1 870 910 112.3 chr1 914 920 12 chr1 930 999 13 My output would be peak1 20 22 23 33.5 90 peak2 20 21.78 112.3 12 13 Here the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

7. Shell Programming and Scripting

Remove duplicates within row and separate column

Hi all I have following kind of input file ESR1 PA156 leflunomide PA450192 leflunomide CHST3 PA26503 docetaxel Pa4586; thalidomide Pa34958; decetaxel docetaxel docetaxel I want to remove duplicates and I want to separate anything before and after PAxxxx entry into columns or... (1 Reply)
Discussion started by: manigrover
1 Replies

8. Shell Programming and Scripting

Separate lines in csv by column content (newbie)

Hello everyone I have a csv file organized just like in the following example: col1,col2,col3,CODE_0, ... , colN col1,col2,col3,CODE_0, ... , colN col1,col2,col3,CODE_1, ... , colN col1,col2,col3,CODE_1, ... , colN col1,col2,col3,CODE_1, ... , colN col1,col2,col3,CODE_2, ... , colN... (7 Replies)
Discussion started by: yomaya
7 Replies

9. UNIX for Dummies Questions & Answers

Grep line to separate column

Hi friends I have a file like this I want output like this probably in excel sheet . Please help Waiting for reply Thanks a lot (14 Replies)
Discussion started by: umapearl
14 Replies

10. Shell Programming and Scripting

separate out the column

I know "awk -F:" will separate out the column by ":" , now if I what to separate out the column by space also , what can I do ? for example : #ps -ef |grep telnet root 10159 702 0 15:45 ? 00:00:00 in.telnetd: 192.168.0.1 how to separate out the column so that the column as below, ... (6 Replies)
Discussion started by: ust
6 Replies
Login or Register to Ask a Question