LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 02-02-2011, 10:37 PM   #1
mauludi
LQ Newbie
 
Registered: Jan 2010
Posts: 21

Rep: Reputation: 0
why "cut -d" command does not work well in my data?


Dear All,

I have data file called "data1" which contain:

76.0023 0.607915 21.9427 29.8115
76.0026 0.135949 2.79735 38.1032
76.007 0.0519359 51.5472 16.0616
76.007 0.667013 16.8161 40.6055
76.0083 0.0713691 26.9012 46.1717
76.0092 0.657112 11.1443 51.7081
76.0148 0.0344147 2.50109 14.1176


I will take data in each column by this "script" file which contain:

cut -d " " -f1 data1 > colom1
cut -d " " -f2 data1 > colom2
cut -d " " -f3 data1 > colom3


"colom1" file is right but "colom2" and "colom3" are wrong.
colom2:

0.607915
0.135949


0.0713691

colom3:


0.0519359
0.667013


where the problem comes from? how to solve that?

thank you for your help

with best wishes
 
Old 02-02-2011, 11:03 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
First thought: you're using TAB and SPACE characters in the
file, but only SPACE for cut.

Possible solution: use awk - it handles ANY whitespace as
separator:
Code:
awk '{print $1 >> "colom1"; print $2 >> "colom2"; print $3 >> "colom3" }' data1

Last edited by Tinkster; 02-02-2011 at 11:05 PM.
 
Old 02-02-2011, 11:53 PM   #3
mauludi
LQ Newbie
 
Registered: Jan 2010
Posts: 21

Original Poster
Rep: Reputation: 0
thank you a lot for your help.
 
  


Reply



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
How to get the "data type" of an "unknown variable" in "C Language" ? Affair Programming 8 06-20-2009 12:30 PM
How to use command grep,cut,awk to cut a data from a file? hocheetiong Linux - Newbie 7 09-11-2008 07:16 PM
" cut command " sharath.bv Programming 5 02-04-2008 02:38 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 01:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:04 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
Open Source Consulting | Domain Registration