LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to use cut command in the shell script (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-use-cut-command-in-the-shell-script-450624/)

narendra.pant 06-01-2006 12:38 PM

how to use cut command in the shell script
 
not able to get it cleared from the man page

jonaskoelker 06-01-2006 01:18 PM

Read www.catb.org/~esr/faqs/smart-questions.html and www.chiark.greenend.org.uk/~sgtatham/bugs.html. What is it you want?

pixellany 06-01-2006 07:17 PM

Quote:

Originally Posted by narendra.pant
not able to get it cleared from the man page

What is your question??!!!!!????

Dark_Helmet 06-01-2006 09:46 PM

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.


All times are GMT -5. The time now is 02:38 AM.