Cut
Cut out selected fields of each line of a file.
Syntax
cut [-b] [-c] [-f] list [-n] [-d delim] [-s] [file]
-b list
The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72 bytes of each line). When -b and -n are used together, list is adjusted so that no multi-byte character is split. If -b is used, the input line should contain 1023 bytes or less.
-c list
The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-f list
The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (useful for table subheadings), unless -s is specified. If -f is used, the input line should contain 1023 characters or less.
list
A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-n
Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split.
-d delim
The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special meaning to the shell must be quoted. delim can be a multi-byte character.
-s
Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be passed through untouched.
file
A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be used.
Examples
name=`who am i | cut -f1 -d' '`
Set name to current login name.
About cut
Cut out selected fields of each line of a file.
Syntax
cut [-b] [-c] [-f] list [-n] [-d delim] [-s] [file]
-b list The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72
bytes of each line). When -b and -n are used together, list is adjusted so that no multi-byte character is split. If -b is used, the input line should contain 1023 bytes or less.
-c list The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (useful for table subheadings), unless -s is specified. If -f is used, the input line should contain 1023 characters or less.
list A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-n Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split.
-d delim The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special meaning to the shell must be quoted. delim can be a multi-byte character.
-s Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be passed through untouched.
file A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be used.
Examples
name=`who am i | cut -f1 -d' '`
Set name to current login name.
WC-UNIX:
$ wc filename X Y Z filename
Cut out selected fields of each line of a file.
Syntax
cut [-b] [-c] [-f] list [-n] [-d delim] [-s] [file]
-b list
The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72 bytes of each line). When -b and -n are used together, list is adjusted so that no multi-byte character is split. If -b is used, the input line should contain 1023 bytes or less.
-c list
The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-f list
The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (useful for table subheadings), unless -s is specified. If -f is used, the input line should contain 1023 characters or less.
list
A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-n
Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split.
-d delim
The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special meaning to the shell must be quoted. delim can be a multi-byte character.
-s
Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be passed through untouched.
file
A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be used.
Examples
name=`who am i | cut -f1 -d' '`
Set name to current login name.
About cut
Cut out selected fields of each line of a file.
Syntax
cut [-b] [-c] [-f] list [-n] [-d delim] [-s] [file]
-b list The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72
bytes of each line). When -b and -n are used together, list is adjusted so that no multi-byte character is split. If -b is used, the input line should contain 1023 bytes or less.
-c list The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (useful for table subheadings), unless -s is specified. If -f is used, the input line should contain 1023 characters or less.
list A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-n Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split.
-d delim The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special meaning to the shell must be quoted. delim can be a multi-byte character.
-s Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be passed through untouched.
file A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be used.
Examples
name=`who am i | cut -f1 -d' '`
Set name to current login name.
WC-UNIX:
$ wc filename X Y Z filename
- X – Number of lines
- Y – Number of words
- Z – Number of bytes
- filename – name of the file
-l : Prints the number of lines in a file. -w : prints the number of words in a file. -c : Displays the count of bytes in a file. -m : prints the count of characters from a file. -L : prints only the length of the longest line in a file.
No comments:
Post a Comment