Computing.Net > Forums > Unix > cut statment

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

cut statment

Reply to Message Icon

Name: charles_cp
Date: November 9, 2003 at 08:13:59 Pacific
OS: AIX
CPU/Ram: 900
Comment:

I have a text file like this:
A Tom Wong
B Mary Chan
C Peter Wu
D Steven Cheung

How to use the "cut" command to display the following:
A Tom Wong
B
C Peter Wu
D Steven Cheung



Sponsored Link
Ads by Google

Response Number 1
Name: Shaun
Date: November 9, 2003 at 13:19:58 Pacific
Reply:

Not sure cut is what you want. That's usually used to extract text. You may want to loop through the file one line at a time and break eack line into fields, then process accordimgly. What would be the general purpose of your script?



0

Response Number 2
Name: Keith
Date: November 11, 2003 at 17:32:48 Pacific
Reply:

'cut' is used to cut all fields, conditionals are better handled with awk, perl, sed, etc.

If you had some file "ick" that had the above, you could execute the following:

awk '!/Mary/ { print } /Mary/ {print $1}' ick2

I'd avoid looping at all cost as it is expensive. Like all things in UNIX, there are 50 ways to do it, 5 of which are optimum. Cheers,

Keith


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: cut statment

cut problem www.computing.net/answers/unix/cut-problem/3506.html

cut and paste (urgent) www.computing.net/answers/unix/cut-and-paste-urgent/6965.html

Help Requested - cut & sed cmds www.computing.net/answers/unix/help-requested-cut-amp-sed-cmds/5224.html