LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-04-2004, 03:42 PM   #16
pony85
LQ Newbie
 
Registered: Aug 2004
Location: Bangalore
Distribution: Redhat Linux 9.0
Posts: 25

Original Poster
Rep: Reputation: 15

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 ??
 
Old 08-04-2004, 03:43 PM   #17
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
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
 
Old 08-04-2004, 03:44 PM   #18
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Quote:
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 ??
What command did you execute to get that result?
 
Old 08-04-2004, 03:49 PM   #19
pony85
LQ Newbie
 
Registered: Aug 2004
Location: Bangalore
Distribution: Redhat Linux 9.0
Posts: 25

Original Poster
Rep: Reputation: 15
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
 
Old 08-04-2004, 03:58 PM   #20
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
Code:
[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...


Cheers,
Tink
 
Old 08-04-2004, 04:00 PM   #21
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Quote:
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.
 
Old 08-04-2004, 04:02 PM   #22
pony85
LQ Newbie
 
Registered: Aug 2004
Location: Bangalore
Distribution: Redhat Linux 9.0
Posts: 25

Original Poster
Rep: Reputation: 15
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.
 
Old 08-04-2004, 04:13 PM   #23
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
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.



Cheers,
Tink
 
Old 08-04-2004, 04:17 PM   #24
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
What I think he did Tink, was execute this sequence:
Code:
[root@localhost root]# cd /bin | ls > wc
[root@localhost root]# ls
[root@localhost root]#
Now, this would indicate he has no files in /root, but that would be impossible, as he created a file called wc with the original command.
 
Old 08-04-2004, 04:19 PM   #25
pony85
LQ Newbie
 
Registered: Aug 2004
Location: Bangalore
Distribution: Redhat Linux 9.0
Posts: 25

Original Poster
Rep: Reputation: 15
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??
 
Old 08-04-2004, 04:33 PM   #26
Charalambos
Member
 
Registered: Aug 2004
Location: Switzerland
Distribution: debian
Posts: 149

Rep: Reputation: 15
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).
 
Old 08-04-2004, 04:41 PM   #27
pony85
LQ Newbie
 
Registered: Aug 2004
Location: Bangalore
Distribution: Redhat Linux 9.0
Posts: 25

Original Poster
Rep: Reputation: 15
thanks i will try that!

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!!!
Quote:
LINUX ROCKS!!!!!
 
Old 08-04-2004, 04:44 PM   #28
pony85
LQ Newbie
 
Registered: Aug 2004
Location: Bangalore
Distribution: Redhat Linux 9.0
Posts: 25

Original Poster
Rep: Reputation: 15
i just tried the command by myself

well i just learnt about pipes so thought of doing something... and Kwel ended up ruining up my ls !!!

cheers...
Pavan.M.V. (pony85)
Quote:
LinuxQuestions.org is really ULTIMATE place for getting your Q`s on Linux solved!! Hats off 2 LinuxQuestions.org
 
Old 08-04-2004, 04:58 PM   #29
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Quote:
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.

Last edited by stickman; 08-04-2004 at 05:03 PM.
 
Old 08-05-2004, 01:16 AM   #30
pony85
LQ Newbie
 
Registered: Aug 2004
Location: Bangalore
Distribution: Redhat Linux 9.0
Posts: 25

Original Poster
Rep: Reputation: 15
Well thats also no use stickman.... The same thing happens when i execute the ls command as a ordinary user...
regards
Pony85
 
  


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
!!!! Urgent, using chown command ? AQG Linux - Security 8 08-12-2005 03:21 PM
URGENT: problem with the command insmod pierre44 Linux - General 3 07-11-2005 08:31 AM
URGENT : pb with insmod command pierre44 Linux - Newbie 1 07-11-2005 06:59 AM
tar command problem:urgent imsajjadali Linux - General 1 01-30-2004 04:50 AM
os command doubt===urgent google_man Solaris / OpenSolaris 10 08-04-2003 09:35 AM

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

All times are GMT -5. The time now is 10:16 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