Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hey guys i found out the size of the ls file in my /bin folder is 0 bytes... and may be this is the reason it is doing nothing. DOES THAT MEAN I FOUND A BUG IN REDHAT 9.0 ??
I guess that depends on what the book was trying to accomplish with the command. The original command as you posted doesn't really do anything useful. This would probably be a better example:
cd /bin && ls | wc
This command does the following in steps:
cd /bin -- changes the current working directory to /bin
&& ls -- if successful then do ls
| wc -- count the words in the ls output
Originally posted by pony85 hey guys i found out the size of the ls file in my /bin folder is 0 bytes... and may be this is the reason it is doing nothing. DOES THAT MEAN I FOUND A BUG IN REDHAT 9.0 ??
[root@localhost root]# cd /bin | ls > wc
[root@localhost root]# ls
[root@localhost root]#
Dude, that just means that you don't have
any files in roots home-directory...
If ls were actually broken bash would
return some sort of error message. And
piping the output of cd into ls and redirecting
that into a file called wc just doesn't make
any sense at all...
Originally posted by pony85 ok type this command at ur shell prompt as root
cd /sbin | ls > wc
and check the size of the ls file in your /bin directory
This command does not do what you think it is doing. It is send the output of "cd /sbin" to the ls command. Since /sbin exists the ls command is acting on null input. Look at the steps individually. "cd /sbin" just returns you to the next prompt unless there is an error. Piping the output of a cd command to ls doesn't make any sense. It makes more sense to cd then ls which is:
cd /sbin && ls
You keep doing "> wc" which is collecting the output the last command. There are two problems with this. First, you littering your file systems with little files called wc everywhere. Secondly, wc is an actual command which may cause problem later. If you did this in the directory where the real wc command exists you would corrupt that command.
Well dude the problem is that it works in a similar way in all the directories even if the dir is not empty and i know it doesnt make any sense but may be its a bug in Redhat 9.0 that the size of ls becomes 0 bytes once this command is executed.
I think the bug is with what you do. Seeing you
do the > wc all the time I wouldn't be surprised
if you had done a ls > ls, which, in an empty
directory, would result in a zero-length file named
ls.
ok Wow u r a genius Tink. i did do ls > ls but can how will my ls file in /bin dir become zero?? and also pleaseeeeeeeeeeeee tell me how can i put it right? will copying the ls file from another redhat 9.0 system help??
Hehe, nice doing.
Copy the ls from an other distro should do it (or from your installation cd-rom even better).
And where the heck did you get that command? Was someone trying to fuck with you?
You should keep out about typing such commands as root, because you can do really harmful and not fixable damage to your linux system.
You should never ever work as root unless you really require being root (e.g to make configuration or somesuch).
Wow!! U know it feels soo gud for the first time i did something which can we used a shell script 2 ruin da ls command hmmm i do write virus on WINDOZE but... Linux is different... Boyyy!! LINUX ROX!!!
Originally posted by pony85 well stickman actually i didnt mean anything. I just tried it as i read bout piping in a Unix book.. but can u please let me know how i can set it right.
What book were your reading? I suspect that you should probably find another book with fewer questionable and dubious commands. Also, doing these types of experiments as root is not really wise unless you like fixing problems that could have been easily avoided. Try working as a regular user. You'll get feedback from the OS about permissions and such that will help you get the command that you really want.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.