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:
[2014-03-13] | [Open System-Linux] |
crontab: A command in linux to automatically start/repeat a process at certian time and interval |
[2014-06-05] | [Open System-Linux] |
SCRIPT command: Save your Linux sessions automatically |
[2014-01-08] | [Open System-Linux] |
SSH Login Setup |
[2014-09-21] | [Open System-Linux] |
How to define command prompt strings in Linux : what are $PS1, $PS2, $PS3 and $PS4? |
[2015-07-18] | [Open System-Linux] |
Creating and Managing Logical Volume Manager in Linux |
Total comments: 0 | |