9:39 PM CUT command in Linux : cut the file vertically | ||||||
CUT- Remove sections from each line of files vertically. This command basically cuts the file vertically and returns a certain field from each line from a file. FORMAT DESCRIPTION Mandatory arguments to long options are mandatory for short options too. -b, --bytes=LIST We are using below file for demo: shanky@localhost:/home/shanky/test:> cat afile1 To print only the 5th character from each line of a file:
-c, --characters=LIST
-d, --delimiter=DELIM
-f, --fields=LIST
-s, --only-delimited
--output-delimiter=STRING
See the difference of above two outputs. In the first output, the delimiter is ":" which is the input delimiter and in second output we have given "space" as output delimiter. Use one, and only one of -b, -c or -f. Each LIST is made up of one range, or many ranges separated by commas. Selected input is written in the same order that it is read, and is written exactly once. Each range is one of:
See below examples executed on the same file:
The above command will print from 5th to 10th byte, character or field | ||||||
|
Related blogs
You may also like to see:
[2015-06-03] | [Open System-Linux] |
STAT command : check file or filesystem statistics |
[2015-06-19] | [Open System-Linux] |
How to create swap file in Linux : Adding extra swap space |
[2016-05-11] | [Open System-Linux] |
An example to understand bash exit code $? in linux. |
[2014-06-05] | [Open System-Linux] |
SCRIPT command: Save your Linux sessions automatically |
[2015-06-01] | [Open System-Linux] |
DIG command : A DNS lookup utility |
Total comments: 0 | |