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-01-18] | [Open System-Linux] |
The JAR archiving tool in Linux |
[2015-03-23] | [Open System-Linux] |
FSCK : Checking and reparing filesystems in Linux |
[2015-06-08] | [Open System-Linux] |
CHAGE command in LINUX |
[2014-09-13] | [Open System-Linux] |
md5sum: calculate and check md5 message digest of a file in Linux |
[2014-10-24] | [Open System-Linux] |
HEXDUMP command in Linux to display the file content in decimal, hexadecimal, octal format |
Total comments: 0 | |