| | |
I need help with the cut command.
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hi everyone,
In part of my script, I'm trying cut out couple of columns from the df -h command.
The ones I want is the Filesystem column and the Mounted On column. This is what I have so far.
And that will get the Filesystem in the first field, but for the next column, I tried different fields and I still keep getting a blank space.
Any help you guys can give will be greatly appreciated!
Thanks!
In part of my script, I'm trying cut out couple of columns from the df -h command.
The ones I want is the Filesystem column and the Mounted On column. This is what I have so far.
Shell Scripting Syntax (Toggle Plain Text)
df -h | cut -d " " -f1
And that will get the Filesystem in the first field, but for the next column, I tried different fields and I still keep getting a blank space.
Any help you guys can give will be greatly appreciated!
Thanks!
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Hi everyone,
In part of my script, I'm trying cut out couple of columns from the df -h command.
The ones I want is the Filesystem column and the Mounted On column. This is what I have so far.
Shell Scripting Syntax (Toggle Plain Text)
df -h | cut -d " " -f1
And that will get the Filesystem in the first field, but for the next column, I tried different fields and I still keep getting a blank space.
Any help you guys can give will be greatly appreciated!
Thanks!
Shell Scripting Syntax (Toggle Plain Text)
df -h | sed -e 's/[ ][ ]*/ /g' | cut -d" " -f1,5
0
#3 Nov 2nd, 2009
You could also use awk:
Shell Scripting Syntax (Toggle Plain Text)
sk@svn:~/devex$ df -h | awk '{ print $1,$2,$5 }'
![]() |
Similar Threads
- Compare 2 tables (Perl)
- using grep, sed, awk to pull links out of an XML file (Shell Scripting)
- Date comparing in Unix shell script (Shell Scripting)
- reverse with cut command (Shell Scripting)
- reading variables with spaces into UNIX (Shell Scripting)
- how to create a submenu in python? (Python)
- help me(PIPES) (C)
Other Threads in the Shell Scripting Forum
- Previous Thread: Counter
- Next Thread: Uix Script Help Need
| Thread Tools | Search this Thread |






