wc vs ls


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers wc vs ls
# 8  
Old 04-27-2006
The good thing about that is we avoid the Useless Use of cat. Why spawn uneccessary processes?

Cheers
ZB
# 9  
Old 04-30-2006
here's why

Why? here's why:
1. if you use < by mistake with a file that is not ASCII you likely will sit and enjoy all this gibberish on a screen and /a beeps with no option to interrupt it as it is dumped directly to the sdout, pipelined cat gives you option for Ctl-C, to interrupt
2. I often don't know precisely what is a problem as I troubleshoot so I use different keys with a pipeline after cat as it saves typing, I don't have to move somewhere into middle line to edit variables.
3. I found this makes cleaner and more readable line for mere mortals who reside in "UNIX for Dummies" forum, as not everyone is "registered geek"
4. I know what is notion UUOC means but it is just another notion for a style for these people who got nothing to worry about but another notion. So let remove some commands from the systems at all. I personally don't care if I will create one more process. I didn't care about it ten years ago when computers had been some 20 times slower, and I certainly will not care today with 99% idle CPU time.

computer it is a tool to make my life more comfortable, not I exists to save it from extra exercise of spawning extra processes.


Quote:
Originally Posted by zazzybob
The good thing about that is we avoid the Useless Use of cat. Why spawn uneccessary processes?

Cheers
ZB

Last edited by amro1; 05-06-2006 at 04:35 PM..
# 10  
Old 05-01-2006
Yes I suppose it's up to you what you do. I look after some systems with hundreds of users logged in at any one time....

If some user decided to do (something like):
Code:
for i in `seq 1 1000`; do
  cat somefile | grep "something"
done

Now we see that the problem isn't just one unecessary process, it's 1000.

This is why I think that best-practice scripting in terms of efficiency should be the pillar of your style, even with the simplest one-liners.

My two cents.

Cheers
ZB
# 11  
Old 05-01-2006
aga...

So do I. If someone does things in fashion that is not perfect it doesn't mean I have to live more pious life to compensate. If someone does "bad" loops it even isn't necessary to put extra process up to put a system to its knees, just make this loop endless ... Smilie
But yes better code causes better moods ... most of time...

Cheers!


Quote:
Originally Posted by zazzybob
Yes I suppose it's up to you what you do. I look after some systems with hundreds of users logged in at any one time....

If some user decided to do (something like):
Code:
for i in `seq 1 1000`; do
  cat somefile | grep "something"
done

Now we see that the problem isn't just one unecessary process, it's 1000.

This is why I think that best-practice scripting in terms of efficiency should be the pillar of your style, even with the simplest one-liners.

My two cents.

Cheers
ZB
# 12  
Old 05-04-2006
Thank you... but a question

I was kind of heart broken when I didnt receive enough replies in the first two days of post. Now, I am really impressed by the number and the substance of the responses. Thank you one and all for take time out to help me.

One thing is still not clear for me... given that wc is upgraded to the correct version, are both wc -c and ls -l expected to return exactly same integer value for byte size (considering ASCII and Unicode - single byte/multibyte -files)?

Thanks again,
Sreenivas
# 13  
Old 05-04-2006
It would be interesting to see the actual discrepancies that your users report - are they completely random or is there a pattern; are the discrepancies small or large; do the discrepancies start at a particular size of file; is there a difference between text and non-text files (I could go on ...)

cheers
# 14  
Old 05-05-2006
Sorry, I should have provided these details to you earlier.

Running the same script as in my initial post for 5 GB text file resulted in discrepancy
=============== Result-5GB =========================
Tue Apr 25 06:07:59 PDT 2006
5327822178
Tue Apr 25 06:07:59 PDT 2006
1032854882
Tue Apr 25 06:37:29 PDT 2006
========================================

A 500 byte unicode (UTF8) file is returning same numbers for both commands. I am not sure if I can infer that there is no difference in counting bytes on text and non-text files.

Thanks!
Sreenivas


Thanks!
Chakri
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question