Bash stampa sottostringa di un campo

Esempi di codice

1
0

bash stampa sottostringa di un campo

# Basic syntax:
awk 'BEGIN {FS="input_delimiter"; OFS="output_delimiter"} {print substr($column_number, start_character, number_characters)}' input_file

# Where:
#	- BEGIN {FS="input_delimiter"; OFS="output_delimiter"} is for setting
#		the input and output field/column delimiters
#	- column_number is the field for which you want a substring
#	- start_character is the number of the first character from the left
#		(inclusive) that you want to incude in the substring
#	- number_characters is the number of characters to print past the 
#		start character (inclusive)

# Example usage:
# Say you had a file like the following and only want the ID #s:
customer	info	ID:123456	account
customer	info	ID:172327	account

# Running:
awk 'BEGIN {FS="\t"; OFS="\t"} {print substr($3, 4, 6)}' input_file

# Would return:
123456
172327

Pagine correlate

Pagine di esempio simili

In altre lingue

Questa pagina è in altre lingue

Русский
..................................................................................................................
English
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................