LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   command (https://www.linuxquestions.org/questions/linux-newbie-8/command-4175443222/)

yaswanth4b7 12-28-2012 02:39 AM

command
 
Hi, i am having a file. data contained in columns so i want to see only 4 th column is there any command to check it?

druuna 12-28-2012 02:42 AM

Quote:

Originally Posted by yaswanth4b7 (Post 4858263)
Hi, i am having a file. data contained in columns so i want to see only 4 th column is there any command to check it?

You can use awk or cut (probably others). Which to use and how to use them depends on the layout of your data.

- The GNU Awk User's Guide
- Linux Commands Directory

yaswanth4b7 12-28-2012 04:25 AM

hi thax for the reply is these command is correct "cut -c 4 data.txt"

sycamorex 12-28-2012 04:45 AM

Quote:

Originally Posted by yaswanth4b7 (Post 4858303)
hi thax for the reply is these command is correct "cut -c 4 data.txt"

Most probably, not. Why don't you try it and see what happens? This is one of the most basic Awk or cut function, please use google search and you'll get LOTS of examples.

druuna 12-28-2012 04:52 AM

Quote:

Originally Posted by yaswanth4b7 (Post 4858303)
hi thax for the reply is these command is correct "cut -c 4 data.txt"

As stated in my previous post: Without knowing what the layout looks like we can point you to commands, not a fully working solution.

Follow sycamorex' advise, it is the only way to learn.

David the H. 12-29-2012 05:52 PM

If I may give some friendly advice...

1) To start with, please use a thread title that has some relevance to your specific problem. "command" could mean almost anything. "Printing only one column?" would be much clearer, and readers who are likely to know the answer will be more likely to click on it.


2) When you post a problem you really need to give more details. Start by explaining the background of your situation, including the environment and tools that are available to you (particularly if it's not a standard Linux setup). Otherwise we have to make assumptions and/or ask you clarifying questions before we can help you.

Then (for text-processing questions at least), provide an actual example of both the input text and the desired output. Finally, be sure to mention any attempts you've already made, and the results you got, including error messages.

Of course, you do have to balance it too. Don't overwhelm us with more detail than is needed to understand your situation.


3) Please take the time to do some research before you post, particularly for common actions like this. There's a whole internet full of advice out there, in addition to the LinuxQuestions archives. A few minutes of searching would certainly answer your question for you, or at least give you leads about where to look next.



4) Finally, when you have time, please read How To Ask Questions The Smart Way. Expressing your questions properly will maximize your chances of getting good results, and save everyone, including you, a lot of time and hassle.



Incidentally, most text processing is done with grep, sed, awk, and the various coreutils like cut. Each of these has both man pages and info pages detailing their options and use, as well as countless examples on the internet.

I particularly recommend taking a look at "info coreutils" for a detailed list of all the applications that it provides.

The shell itself has several built-in features for string manipulation too.


4) Finally, when you have time, please read How To Ask Questions The Smart Way. Expressing your questions properly will maximize your chances of getting good results, and save everyone, including you, a lot of time and hassle.


Good luck!


All times are GMT -5. The time now is 08:11 AM.