LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 06-01-2006, 12:38 PM   #1
narendra.pant
Member
 
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, 01:18 PM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 46
Read www.catb.org/~esr/faqs/smart-questions.html and www.chiark.greenend.org.uk/~sgtatham/bugs.html. What is it you want?
 
Old 06-01-2006, 07:17 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

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

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
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:
Code:
$ echo "This is a test string" | cut   -f 4     -d ' '
test

$ 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.
 
  


Reply


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 12:33 AM
Command in shell script Grassie Coetzee Linux - Software 1 03-13-2005 11:42 AM
command not found (My shell script) Swift&Smart Linux - Software 3 05-15-2004 11:14 PM
shell script - cut off the '^M' d-fens Programming 5 07-20-2003 11:20 AM


All times are GMT -5. The time now is 05:26 AM.

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