Linux Commands Helper
💬 Your AI-powered Linux assistant
cut Command - Remove Sections from Each Line of Files
The cut command is used to extract sections from each line of input, usually from text files or streams. It is commonly used to extract columns or fields from delimited data.
Syntax
cut [options] [file...]
Examples
cut -d ':' -f 1 /etc/passwd
Extract the first field (username) from /etc/passwd using ':' as the delimiter.
echo "a,b,c" | cut -d ',' -f 2
Extract the second field from a comma-separated string.
cut -c 1-5 file.txt
Extract the first five characters of each line in file.txt.
Notes
- Use
-d
to specify a delimiter and-f
to specify fields. - Use
-c
to specify character positions. - Can be combined with
cat
andgrep
for advanced text processing.