SlideShare a Scribd company logo
For more details visits :- http://manojlinux.weebly.com
Manoj kumar pradhan Ph- 7411834957
Cut Command in Unix ( Linux) Examples
Cut command in unix (or linux) is used to select sections of text from each line of files. You can use
the cut command to select fields or columns from a line by specifying a delimiter or you can select a
portion of text by specifying the range or characters. Basically the cut command slices a line and
extracts the text.
Unix Cut Command Example
We will see the usage of cut command by considering the below text file as an example
> cat file.txt
unix or linux os
is unix good os
is linux good os
1. Write a unix/linux cut command to print characters by position?
The cut command can be used to print characters in a line by specifying the position of the
characters. To print the characters in a line, use the -c option in cut command
cut -c4 file.txt
x
u
l
The above cut command prints the fourth character in each line of the file. You can print more than
one character at a time by specifying the character positions in a comma separated list as shown in
the below example
For more details visits :- http://manojlinux.weebly.com
Manoj kumar pradhan Ph- 7411834957
cut -c4,6 file.txt
xo
ui
ln
This command prints the fourth and sixth character in each line.
2.Write a unix/linux cut command to print characters by range?
You can print a range of characters in a line by specifying the start and end position of the
characters.
cut -c4-7 file.txt
x or
unix
linu
The above cut command prints the characters from fourth position to the seventh position in each
line. To print the first six characters in a line, omit the start position and specify only the end position.
cut -c-6 file.txt
unix o
is uni
is lin
To print the characters from tenth position to the end, specify only the start position and omit the end
position.
For more details visits :- http://manojlinux.weebly.com
Manoj kumar pradhan Ph- 7411834957
cut -c10- file.txt
inux os
ood os
good os
If you omit the start and end positions, then the cut command prints the entire line.
cut -c- file.txt
3.Write a unix/linux cut command to print the fields using the delimiter?
You can use the cut command just as awk command to extract the fields in a file using a delimiter.
The -d option in cut command can be used to specify the delimiter and -f option is used to specify
the field position.
cut -d' ' -f2 file.txt
or
unix
linux
This command prints the second field in each line by treating the space as delimiter. You can print
more than one field by specifying the position of the fields in a comma delimited list.
cut -d' ' -f2,3 file.txt
For more details visits :- http://manojlinux.weebly.com
Manoj kumar pradhan Ph- 7411834957
or linux
unix good
linux good
The above command prints the second and third field in each line.
Note: If the delimiter you specified is not exists in the line, then the cut command prints the entire
line. To suppress these lines use the -s option in cut command.
4. Write a unix/linux cut command to display range of fields?
You can print a range of fields by specifying the start and end position.
cut -d' ' -f1-3 file.txt
The above command prints the first, second and third fields. To print the first three fields, you can
ignore the start position and specify only the end position.
cut -d' ' -f-3 file.txt
To print the fields from second fields to last field, you can omit the last field position.
cut -d' ' -f2- file.txt
5. Write a unix/linux cut command to display the first field from /etc/passwd file?
The /etc/passwd is a delimited file and the delimiter is a colon (:). The cut command to display the
first field in /etc/passwd file is
For more details visits :- http://manojlinux.weebly.com
Manoj kumar pradhan Ph- 7411834957
cut -d':' -f1 /etc/passwd
6. The input file contains the below text
> cat filenames.txt
logfile.dat
sum.pl
add_int.sh
Using the cut command extract the portion after the dot.
First reverse the text in each line and then apply the command on it.
rev filenames.txt | cut -d'.' -f1

More Related Content

Viewers also liked

ุงุฎุชุตุงุฑูŠ ู„ู„ุชุตู…ูŠู… ุงู„ุชุนู„ูŠู…ูŠ
ุงุฎุชุตุงุฑูŠ ู„ู„ุชุตู…ูŠู… ุงู„ุชุนู„ูŠู…ูŠุงุฎุชุตุงุฑูŠ ู„ู„ุชุตู…ูŠู… ุงู„ุชุนู„ูŠู…ูŠ
ุงุฎุชุตุงุฑูŠ ู„ู„ุชุตู…ูŠู… ุงู„ุชุนู„ูŠู…ูŠ
ssaa2020
ย 
XPagesDay 2016 ใ€Œ้–‹็™บไบ‹ไพ‹ - XPages ใงไฝœใ‚‹ๅ‹•็”ป้–ฒ่ฆงใ‚ตใ‚คใƒˆใ€
XPagesDay 2016 ใ€Œ้–‹็™บไบ‹ไพ‹ - XPages ใงไฝœใ‚‹ๅ‹•็”ป้–ฒ่ฆงใ‚ตใ‚คใƒˆใ€XPagesDay 2016 ใ€Œ้–‹็™บไบ‹ไพ‹ - XPages ใงไฝœใ‚‹ๅ‹•็”ป้–ฒ่ฆงใ‚ตใ‚คใƒˆใ€
XPagesDay 2016 ใ€Œ้–‹็™บไบ‹ไพ‹ - XPages ใงไฝœใ‚‹ๅ‹•็”ป้–ฒ่ฆงใ‚ตใ‚คใƒˆใ€
tshost
ย 
XPagesDay 2016 ใ€Œ็งใ‹ใ‚™ใƒใƒžใฃใŸๅคฑๆ•—ไพ‹ใ€
XPagesDay 2016 ใ€Œ็งใ‹ใ‚™ใƒใƒžใฃใŸๅคฑๆ•—ไพ‹ใ€XPagesDay 2016 ใ€Œ็งใ‹ใ‚™ใƒใƒžใฃใŸๅคฑๆ•—ไพ‹ใ€
XPagesDay 2016 ใ€Œ็งใ‹ใ‚™ใƒใƒžใฃใŸๅคฑๆ•—ไพ‹ใ€
tshost
ย 
Notesใจconnections cloudใ‚’้€ฃๆบ
Notesใจconnections cloudใ‚’้€ฃๆบNotesใจconnections cloudใ‚’้€ฃๆบ
Notesใจconnections cloudใ‚’้€ฃๆบ
Haruyuki Nakano
ย 
El whats app como herramienta educativa
El whats app como herramienta educativaEl whats app como herramienta educativa
El whats app como herramienta educativa
Yusmary Palacios
ย 
Notes ๆŠ€่ก“่€…ใฎใŸใ‚ใฎ ใฏใ˜ใ‚ใฆใฎ XPages ่ฌ›ๅบง (XPagesDay 2015)
Notes ๆŠ€่ก“่€…ใฎใŸใ‚ใฎใฏใ˜ใ‚ใฆใฎ XPages ่ฌ›ๅบง (XPagesDay 2015)Notes ๆŠ€่ก“่€…ใฎใŸใ‚ใฎใฏใ˜ใ‚ใฆใฎ XPages ่ฌ›ๅบง (XPagesDay 2015)
Notes ๆŠ€่ก“่€…ใฎใŸใ‚ใฎ ใฏใ˜ใ‚ใฆใฎ XPages ่ฌ›ๅบง (XPagesDay 2015)
Takeshi Yoshida
ย 
Walking Working-Surface by ISRI
Walking Working-Surface by ISRIWalking Working-Surface by ISRI
Walking Working-Surface by ISRI
Atlantic Training, LLC.
ย 

Viewers also liked (7)

ุงุฎุชุตุงุฑูŠ ู„ู„ุชุตู…ูŠู… ุงู„ุชุนู„ูŠู…ูŠ
ุงุฎุชุตุงุฑูŠ ู„ู„ุชุตู…ูŠู… ุงู„ุชุนู„ูŠู…ูŠุงุฎุชุตุงุฑูŠ ู„ู„ุชุตู…ูŠู… ุงู„ุชุนู„ูŠู…ูŠ
ุงุฎุชุตุงุฑูŠ ู„ู„ุชุตู…ูŠู… ุงู„ุชุนู„ูŠู…ูŠ
ย 
XPagesDay 2016 ใ€Œ้–‹็™บไบ‹ไพ‹ - XPages ใงไฝœใ‚‹ๅ‹•็”ป้–ฒ่ฆงใ‚ตใ‚คใƒˆใ€
XPagesDay 2016 ใ€Œ้–‹็™บไบ‹ไพ‹ - XPages ใงไฝœใ‚‹ๅ‹•็”ป้–ฒ่ฆงใ‚ตใ‚คใƒˆใ€XPagesDay 2016 ใ€Œ้–‹็™บไบ‹ไพ‹ - XPages ใงไฝœใ‚‹ๅ‹•็”ป้–ฒ่ฆงใ‚ตใ‚คใƒˆใ€
XPagesDay 2016 ใ€Œ้–‹็™บไบ‹ไพ‹ - XPages ใงไฝœใ‚‹ๅ‹•็”ป้–ฒ่ฆงใ‚ตใ‚คใƒˆใ€
ย 
XPagesDay 2016 ใ€Œ็งใ‹ใ‚™ใƒใƒžใฃใŸๅคฑๆ•—ไพ‹ใ€
XPagesDay 2016 ใ€Œ็งใ‹ใ‚™ใƒใƒžใฃใŸๅคฑๆ•—ไพ‹ใ€XPagesDay 2016 ใ€Œ็งใ‹ใ‚™ใƒใƒžใฃใŸๅคฑๆ•—ไพ‹ใ€
XPagesDay 2016 ใ€Œ็งใ‹ใ‚™ใƒใƒžใฃใŸๅคฑๆ•—ไพ‹ใ€
ย 
Notesใจconnections cloudใ‚’้€ฃๆบ
Notesใจconnections cloudใ‚’้€ฃๆบNotesใจconnections cloudใ‚’้€ฃๆบ
Notesใจconnections cloudใ‚’้€ฃๆบ
ย 
El whats app como herramienta educativa
El whats app como herramienta educativaEl whats app como herramienta educativa
El whats app como herramienta educativa
ย 
Notes ๆŠ€่ก“่€…ใฎใŸใ‚ใฎ ใฏใ˜ใ‚ใฆใฎ XPages ่ฌ›ๅบง (XPagesDay 2015)
Notes ๆŠ€่ก“่€…ใฎใŸใ‚ใฎใฏใ˜ใ‚ใฆใฎ XPages ่ฌ›ๅบง (XPagesDay 2015)Notes ๆŠ€่ก“่€…ใฎใŸใ‚ใฎใฏใ˜ใ‚ใฆใฎ XPages ่ฌ›ๅบง (XPagesDay 2015)
Notes ๆŠ€่ก“่€…ใฎใŸใ‚ใฎ ใฏใ˜ใ‚ใฆใฎ XPages ่ฌ›ๅบง (XPagesDay 2015)
ย 
Walking Working-Surface by ISRI
Walking Working-Surface by ISRIWalking Working-Surface by ISRI
Walking Working-Surface by ISRI
ย 

Similar to Cut command in unix

Unix - Filters
Unix - FiltersUnix - Filters
Unix - Filters
Dr. Girish GS
ย 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
SaileshB5
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
ย 
COMMAND.pptx
COMMAND.pptxCOMMAND.pptx
COMMAND.pptx
4AL20CS071MAYUR
ย 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
Prabu Cse
ย 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
Prabu Cse
ย 
University of North Texas 2 The sed Stream Editor .docx
University of North Texas 2 The sed Stream Editor .docxUniversity of North Texas 2 The sed Stream Editor .docx
University of North Texas 2 The sed Stream Editor .docx
ouldparis
ย 
Handling Files Under Unix.pptx
Handling Files Under Unix.pptxHandling Files Under Unix.pptx
Handling Files Under Unix.pptx
Harsha Patel
ย 
Handling Files Under Unix.pptx
Handling Files Under Unix.pptxHandling Files Under Unix.pptx
Handling Files Under Unix.pptx
Harsha Patel
ย 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .ppt
PDhivyabharathi2
ย 
Basic commands
Basic commandsBasic commands
Basic commands
ambilivava
ย 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
Akkamahadevi Gowda
ย 

Similar to Cut command in unix (20)

Unix - Filters
Unix - FiltersUnix - Filters
Unix - Filters
ย 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
ย 
COMMAND.pptx
COMMAND.pptxCOMMAND.pptx
COMMAND.pptx
ย 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
ย 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
ย 
University of North Texas 2 The sed Stream Editor .docx
University of North Texas 2 The sed Stream Editor .docxUniversity of North Texas 2 The sed Stream Editor .docx
University of North Texas 2 The sed Stream Editor .docx
ย 
Handling Files Under Unix.pptx
Handling Files Under Unix.pptxHandling Files Under Unix.pptx
Handling Files Under Unix.pptx
ย 
Handling Files Under Unix.pptx
Handling Files Under Unix.pptxHandling Files Under Unix.pptx
Handling Files Under Unix.pptx
ย 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .ppt
ย 
Basic commands
Basic commandsBasic commands
Basic commands
ย 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
ย 

Recently uploaded

HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
ย 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
Celine George
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
ย 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
ย 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
ย 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
ย 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
ย 
CHUYรŠN ฤแป€ ร”N TแบฌP Vร€ PHรT TRIแป‚N Cร‚U HแปŽI TRONG ฤแป€ MINH HแปŒA THI TแปT NGHIแป†P THPT ...
CHUYรŠN ฤแป€ ร”N TแบฌP Vร€ PHรT TRIแป‚N Cร‚U HแปŽI TRONG ฤแป€ MINH HแปŒA THI TแปT NGHIแป†P THPT ...CHUYรŠN ฤแป€ ร”N TแบฌP Vร€ PHรT TRIแป‚N Cร‚U HแปŽI TRONG ฤแป€ MINH HแปŒA THI TแปT NGHIแป†P THPT ...
CHUYรŠN ฤแป€ ร”N TแบฌP Vร€ PHรT TRIแป‚N Cร‚U HแปŽI TRONG ฤแป€ MINH HแปŒA THI TแปT NGHIแป†P THPT ...
Nguyen Thanh Tu Collection
ย 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
ย 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
Kalna College
ย 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
sonukumargpnirsadhan
ย 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
ย 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
ย 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
ย 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
ย 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
OH TEIK BIN
ย 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
ย 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
ย 
220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
Kalna College
ย 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
ย 

Recently uploaded (20)

HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
ย 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
ย 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
ย 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
ย 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
ย 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
ย 
CHUYรŠN ฤแป€ ร”N TแบฌP Vร€ PHรT TRIแป‚N Cร‚U HแปŽI TRONG ฤแป€ MINH HแปŒA THI TแปT NGHIแป†P THPT ...
CHUYรŠN ฤแป€ ร”N TแบฌP Vร€ PHรT TRIแป‚N Cร‚U HแปŽI TRONG ฤแป€ MINH HแปŒA THI TแปT NGHIแป†P THPT ...CHUYรŠN ฤแป€ ร”N TแบฌP Vร€ PHรT TRIแป‚N Cร‚U HแปŽI TRONG ฤแป€ MINH HแปŒA THI TแปT NGHIแป†P THPT ...
CHUYรŠN ฤแป€ ร”N TแบฌP Vร€ PHรT TRIแป‚N Cร‚U HแปŽI TRONG ฤแป€ MINH HแปŒA THI TแปT NGHIแป†P THPT ...
ย 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
ย 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
ย 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
ย 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ย 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
ย 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
ย 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
ย 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
ย 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
ย 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
ย 
220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
ย 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
ย 

Cut command in unix

  • 1. For more details visits :- http://manojlinux.weebly.com Manoj kumar pradhan Ph- 7411834957 Cut Command in Unix ( Linux) Examples Cut command in unix (or linux) is used to select sections of text from each line of files. You can use the cut command to select fields or columns from a line by specifying a delimiter or you can select a portion of text by specifying the range or characters. Basically the cut command slices a line and extracts the text. Unix Cut Command Example We will see the usage of cut command by considering the below text file as an example > cat file.txt unix or linux os is unix good os is linux good os 1. Write a unix/linux cut command to print characters by position? The cut command can be used to print characters in a line by specifying the position of the characters. To print the characters in a line, use the -c option in cut command cut -c4 file.txt x u l The above cut command prints the fourth character in each line of the file. You can print more than one character at a time by specifying the character positions in a comma separated list as shown in the below example
  • 2. For more details visits :- http://manojlinux.weebly.com Manoj kumar pradhan Ph- 7411834957 cut -c4,6 file.txt xo ui ln This command prints the fourth and sixth character in each line. 2.Write a unix/linux cut command to print characters by range? You can print a range of characters in a line by specifying the start and end position of the characters. cut -c4-7 file.txt x or unix linu The above cut command prints the characters from fourth position to the seventh position in each line. To print the first six characters in a line, omit the start position and specify only the end position. cut -c-6 file.txt unix o is uni is lin To print the characters from tenth position to the end, specify only the start position and omit the end position.
  • 3. For more details visits :- http://manojlinux.weebly.com Manoj kumar pradhan Ph- 7411834957 cut -c10- file.txt inux os ood os good os If you omit the start and end positions, then the cut command prints the entire line. cut -c- file.txt 3.Write a unix/linux cut command to print the fields using the delimiter? You can use the cut command just as awk command to extract the fields in a file using a delimiter. The -d option in cut command can be used to specify the delimiter and -f option is used to specify the field position. cut -d' ' -f2 file.txt or unix linux This command prints the second field in each line by treating the space as delimiter. You can print more than one field by specifying the position of the fields in a comma delimited list. cut -d' ' -f2,3 file.txt
  • 4. For more details visits :- http://manojlinux.weebly.com Manoj kumar pradhan Ph- 7411834957 or linux unix good linux good The above command prints the second and third field in each line. Note: If the delimiter you specified is not exists in the line, then the cut command prints the entire line. To suppress these lines use the -s option in cut command. 4. Write a unix/linux cut command to display range of fields? You can print a range of fields by specifying the start and end position. cut -d' ' -f1-3 file.txt The above command prints the first, second and third fields. To print the first three fields, you can ignore the start position and specify only the end position. cut -d' ' -f-3 file.txt To print the fields from second fields to last field, you can omit the last field position. cut -d' ' -f2- file.txt 5. Write a unix/linux cut command to display the first field from /etc/passwd file? The /etc/passwd is a delimited file and the delimiter is a colon (:). The cut command to display the first field in /etc/passwd file is
  • 5. For more details visits :- http://manojlinux.weebly.com Manoj kumar pradhan Ph- 7411834957 cut -d':' -f1 /etc/passwd 6. The input file contains the below text > cat filenames.txt logfile.dat sum.pl add_int.sh Using the cut command extract the portion after the dot. First reverse the text in each line and then apply the command on it. rev filenames.txt | cut -d'.' -f1