LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 05-01-2010, 03:54 PM   #1
j123
LQ Newbie
 
Registered: Mar 2010
Posts: 12

Rep: Reputation: 0
problem cutting values


Hi guys, basically i'm writing a script which cuts values from a file and counts the number of unique values. The problem I'm having is that basically it shows in two different tables one above the other, when I want it in one.

the text file looks like this

123456 mr smith 6 purchases oct 2007
000012 mr jones 2 purchases nov 2000

the code i have cuts it works fine and looks like grep $VALUE cut -d f1
this is the code i'm using to count the unique files;
file | awk '{print $1}' | sort | uniq | wc -l

i can't seem to be able to put the cut code with the sorting code together without it either printing the unique characters of the entire text only, or just printing out the data with the number underneath e.g.

123456 mr jones 6 purchases oct 2007
000012 mr smith 2 purchases nov 2000
12

i've tried putting the sorting part as a variable e.g. UNIQUE = file | awk '{print $1}' | sort | uniq | wc -l then put awk print '{print $1, $2, $3, $UNIQUE}' but that hasn't worked either

any help would be great cheers
 
Old 05-01-2010, 08:32 PM   #2
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
...Without more context, it will not be possible for us to help you. Please post the rest of your script (the entire thing so far) and also explain exactly what you want to do with it, in as few words as possible.

For example:
I want my script to read a file, and output only the number of unique values in the first column.

Please also give us a bigger sample from your file.
 
  


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
Problem when invoking the values of variabled from different program vjayraghavan Linux - Newbie 6 05-21-2009 05:05 AM
problem in manipulation of float values in K shell Lakki Linux - Software 2 03-28-2009 01:16 AM
Problem displaying Bash array values. shinobi59 Programming 3 01-17-2006 05:45 PM
socket dont get/set values (c problem) alaios Programming 6 09-20-2005 04:51 AM
Problem dualbooting XP and Linux. Lilo isn't cutting it... Lepinski Linux - Newbie 5 04-05-2004 07:40 PM


All times are GMT -5. The time now is 08:37 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration