Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-01-2006, 01:38 PM   #1
Registered: Mar 2006
Posts: 86

Rep: Reputation: 15
how to use cut command in the shell script

not able to get it cleared from the man page
Old 06-01-2006, 02:18 PM   #2
Senior Member
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
Read and What is it you want?
Old 06-01-2006, 08:17 PM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Originally Posted by narendra.pant
not able to get it cleared from the man page
What is your question??!!!!!????
Old 06-01-2006, 10:46 PM   #4
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
I'm guessing non-native English, and that the question is "I don't understand the man page for cut, and I need to use it in a shell script. Can you explain it?"

Assuming that's the case, use cut just like any other command. Use the -f and -d arguments to cut to determine what information you want. For instance, look at these commands executed from a prompt:
$ echo "This is a test string" | cut   -f 4     -d ' '

$ echo "This is a test string" | cut   -f 3-4   -d ' '
a test

$ echo "This is a test string" | cut   -f 4-    -d ' '
test string

$ echo "This is a test string" | cut   -f 3     -d 's'
 a te

$ echo "This is a test string" | cut   -f 3-4   -d 's'
 a test 
Spaces were used the separate the options to cut so they would be less confusing--the spaces are not necessary otherwise.

If you have problems understanding a man page, the easiest thing to do is experiment. For userspace commands (like cut, cat, sed, grep, etc.), you're not going to break your machine by playing ith them. Don't understand an option? Try running the command with the option, examine the output, run the command again without the option, and compare. Don't make life difficult by waiting for someone else to tell you the answer... they may not, and they may be wrong.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 01:33 AM
Command in shell script Grassie Coetzee Linux - Software 1 03-13-2005 12:42 PM
command not found (My shell script) Swift&Smart Linux - Software 3 05-16-2004 12:14 AM
shell script - cut off the '^M' d-fens Programming 5 07-20-2003 12:20 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration