LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to use Cut (http://www.linuxquestions.org/questions/linux-general-1/how-to-use-cut-672217/)

ZAMO 09-25-2008 01:31 AM

How to use Cut
 
Hi all,

Am trying to cut the kilobytes(K) or Megabytes(M) from the following. But am unable to get the help from man page of cut.

Code:

ls -lht myfile |awk '{print $5}' |cut ???

Say if the file size 12M , then I want to truncate the "M" from it and need only 12.


Thanks

ghostdog74 09-25-2008 01:34 AM

Code:

ls -lht 9115.THM | awk '{print $5+0}'

ZAMO 09-25-2008 02:13 AM

Thanks a lot :)

Cheers to become the Senior Member Soon :)

trickykid 09-25-2008 11:39 AM

cut is like awk but is only the basic portion of it. It only cuts or removes from each line in a file or output. In this case, you could have used cut to grab the size but cut can't eliminate the M, otherwords, it can't really manipulate the output in anyway.

Use cut if you don't need to manipulate the output, use awk if you do. That's how I approach these two commands.


All times are GMT -5. The time now is 01:56 AM.