LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 06-14-2010, 07:48 PM   #1
krack3rz
LQ Newbie
 
Registered: Jan 2010
Posts: 6

Rep: Reputation: 0
Unhappy temporarily broken bash, need explanation


i was fiddling with some new commands i learned and typed something weird. Then bash broke on me for a while. here's the command i typed while in /bin

bash > less

i believe i was in "sudo su" as the moment. i want to understand this because when I typed it bash didnt work. i tried to type "ls" after and it didnt result in anything. but thats not all it didnt receive any commands.
Was this a crash? and why/how did it fix itself after i logged off.

any info. would be helpful.
Running: Linux [Gnome]
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-14-2010, 08:17 PM   #2
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
No it did not crash. When you type bash in at a command prompt it will create a new instance of bash running on the terminal. The command bash > less will redirect the output for bash into the input for less. Since less will read so many lines from stdout and then wait for the user to hit a key to continue.

Because in essence you were then in less and less does not pass keyboard commands out to bash by default you had a terminal waiting for output from bash and no way to input anything into bash thus no output. You may have had a way to terminate less but I am not on a linux system ATM so I am not sure.
 
Old 06-14-2010, 08:18 PM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,546
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,
Let me man that for you;

Quote:
excerpt 'man bash';
NAME

bash - GNU Bourne-Again SHell SYNOPSIS

bash [options] [file] COPYRIGHT

Bash is Copyright (C) 1989-2004 by the Free Software Foundation, Inc. DESCRIPTION

Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh). Bash is intended to be a conformant implementation of the IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2).
Quote:
excerpt 'man less';

less - opposite of more SYNOPSIS

less -?
less --help
less -V
less --version
less [-[+]aBcCdeEfFgGiIJLmMnNqQrRsSuUVwWX~]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
[-# shift] [+[+]cmd] [--] [filename]...
(See the OPTIONS section for alternate option syntax with long option names.)
DESCRIPTION

Less is a program similar to more (1), but which allows backward movement in the file as well as forward movement. Also, less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi (1). Less uses termcap (or terminfo on some systems), so it can run on a variety of terminals. There is even limited support for hardcopy terminals. (On a hardcopy terminal, lines which should be printed at the top of the screen are prefixed with a caret.) Commands are based on both more and vi. Commands may be preceded by a decimal number, called N in the descriptions below. The number is used by some commands, as indicated.
As you should know the '>' character is used for redirection. So your command 'bash > less' should be obvious if you read the 'man command' above.

I suggest that you look at the following links to aid you for future use in understanding;

Linux Documentation Project
Rute Tutorial & Exposition
Linux Command Guide
Utimate Linux Newbie Guide
LinuxSelfHelp
Getting Started with Linux
Bash Reference Manual
Advanced Bash-Scripting Guide
Linux Home Networking
Virtualiation- Top 10


The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!

Last edited by onebuck; 06-15-2010 at 08:35 AM. Reason: edit magled url
 
Old 06-15-2010, 02:49 AM   #4
geoff_f
Member
 
Registered: May 2003
Location: Canberra, Australia
Distribution: openSUSE 11.3
Posts: 445

Rep: Reputation: 31
Quote:
Originally Posted by exvor
The command bash > less will redirect the output for bash into the input for less.
No, you are confusing that with 'bash | less'. 'bash > less' will direct the output of the command 'bash' to a file called 'less' in the user's current directory.

krack3rz, bash is the underlying program that the terminal uses to run its operations. You don't need to run 'bash' from within the terminal; it's already running for you.

A good reference to understand bash is here: http://www.gnu.org/software/bash/manual/bashref.html.

onebuck, you'll need to change your Bash Reference Manual link to end in .html. It currently gets a 404 - Page Not Found.
 
Old 06-15-2010, 08:37 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,546
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Quote:
Originally Posted by geoff_f View Post
<snip>

onebuck, you'll need to change your Bash Reference Manual link to end in .html. It currently gets a 404 - Page Not Found.
Thanks! I mangled it when copied originally.
Fixed!
 
Old 06-15-2010, 02:33 PM   #6
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Rep: Reputation: 34
Quote:
Originally Posted by onebuck View Post
Hi,
Let me man that for you;

As you should know the '>' character is used for redirection. So your command 'bash > less' should be obvious if you read the 'man command' above.

I suggest that you look at the following links to aid you for future use in understanding;

Linux Documentation Project
Rute Tutorial & Exposition
Linux Command Guide
Utimate Linux Newbie Guide
LinuxSelfHelp
Getting Started with Linux
Bash Reference Manual
Advanced Bash-Scripting Guide
Linux Home Networking
Virtualiation- Top 10


The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
Why are you being so harsh? The original poster doesn't seem to know what > and | are, else they wouldn't be asking the question. And dumping man pages and links doesn't help if they don't know what to look for.

As geoff_f mentioned, running

Code:
$ bash > less
will invoke a new instance of the shell, but all non-error output will be saved to a file called 'less'. The command 'less' is not involved in any way. If you type 'exit' it will return you to the previous shell that ran the above command and all will be fine. If you check your current directory it will contain a file called 'less' which has all the output you did not see (the output you expected, and assumed was because bash broke).

Code:
$ pwd
/tmp/test
$ ls
poem.txt
$ cat poem.txt 
Here's a text file with some text in it.
$ bash > less
$ pwd
$ ls
$ cat poem.txt
$ exit
exit
$ ls
less  poem.txt
$ cat less
/tmp/test
less
poem.txt
Here's a text file with some text in it.
The contents of the file 'less' contain four lines, which are the outputs of the three commands I ran after doing 'bash > less'.

Does this help clarify what you did?

-AM
 
3 members found this post helpful.
Old 06-15-2010, 03:09 PM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,546
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Quote:
Originally Posted by student04 View Post
Why are you being so harsh? The original poster doesn't seem to know what > and | are, else they wouldn't be asking the question. And dumping man pages and links doesn't help if they don't know what to look for.

<snip>

-AM
Please point out what or where you feel is harsh with my response to the OP? I never mentioned the '|' character. No, the OP was experimenting and not knowing what he/she was doing period. So get off the high horse. '<' Now that may seem harsh but not intended as so. Just a plain statement of fact. If you don't have something to contribute as to my posts to the OP then let it be. Wait, did I see a 'moderator' label. NO!

 
1 members found this post helpful.
Old 06-15-2010, 04:32 PM   #8
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Rep: Reputation: 34
Quote:
Originally Posted by onebuck View Post
Hi,


Please point out what or where you feel is harsh with my response to the OP?
Wording such as, "let me man that for you", "as you should know", and "should be obvious" --in my opinion-- are condescending. This *should be obvious* to you Sorry if you didn't intend it that way originally, that's just how it read to me in my head.

Quote:
I never mentioned the '|' character.
This is indeed true, but I don't see the relevance in mentioning this. You confused > for |.

Quote:
No, the OP was experimenting and not knowing what he/she was doing period. So get off the high horse. '<' Now that may seem harsh but not intended as so. Just a plain statement of fact. If you don't have something to contribute as to my posts to the OP then let it be. Wait, did I see a 'moderator' label. NO!

I did indeed have something to contribute, and it was pointing out that your post was misleading. So I gave my own example.
 
Old 06-15-2010, 05:36 PM   #9
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,546
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Quote:
Originally Posted by student04 View Post
Wording such as, "let me man that for you", "as you should know", and "should be obvious" --in my opinion-- are condescending. This *should be obvious* to you Sorry if you didn't intend it that way originally, that's just how it read to me in my head.

This is indeed true, but I don't see the relevance in mentioning this. You confused > for |.

I did indeed have something to contribute, and it was pointing out that your post was misleading. So I gave my own example.
That's your opinion about how things are worded. Get over it! You will find others do the same type of posting and it is not meant to be condescending. Loads of newbie's are not aware of the system documentation and sometimes need to have some things pointed out to them. We're not spoon feeding here but if you want to then by all means, do it. I didn't judge how your presentation(s) were made except for your attempt at spanking me when it's not justified or necessary.

I did not confuse the two characters but the OP did utilize the '>'. I posted excerpts for man 'bash' & the command 'less'. His redirect was faulty. I never addressed the '|' period. I did not confuse either. Your reading things into this. I've re-read what I posted so I feel what was presented is correct.

As far as contribution, re-read what I said. I never said anything about the information that you presented to the OP. I was speaking of your contributions or comments to ME. You are mixing my posts with other members therefore confused and trying to justify.

If you feel what I presented was misleading then point it out and I'll see if it can be clarified.
I could have expanded but at the time was directly addressing the usage by the OP;
Quote:
As you should know the '>' character is used for redirection. So your command 'bash > less' should be obvious if you read the 'man command' above.

[example] If this was the confusion by omission then;

As you should know the '>' character is used for redirection that will direct the output to the trailing file that you called 'less'. So your command 'bash > less' should be obvious if you read the 'man command' above for 'bash'. Where you are using the 'bash' which is "Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file." the command structure of 'bash > less' will direct the output of the new bash sh to the file less not the command 'less'. But even then it should be obvious that the creation of a new sh will be created if you read the 'man bash'. If you are thinking it would be to the command 'less' then look at the pipe character '|'. The command 'less' will sit an wait for input.

'OP' you are misusing the commands and structure of the commands if you expected the 'less' command to be executed by use of the character '>'. As others have pointed out it would be the pipe '|' character used. Look at the suggested links. They will help. [/example]
@student04 if that pacifies then 'Enough said!'.
 
Old 06-15-2010, 05:56 PM   #10
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Yeah don't let the wording of some responses seam to be harsh, they are probably not ment that way. Sometimes my responses I will write into them some whimsiclness and it may come off as me being an ass.

Anyway I was thinking of bash | less indeed not bash > less.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
help for explanation for two lines code in bash cooky_jun Linux - Newbie 5 05-21-2010 08:27 AM
Bash Scripting explanation mijohnst Linux - General 8 08-29-2009 11:32 AM
Bash Script Now Broken paulclark Programming 10 08-11-2009 01:45 PM
Broken Dependencies - Bash lolwtfnoob Debian 14 04-24-2009 10:51 AM
explanation on some bash syntax slzckboy Programming 2 10-02-2005 07:06 AM


All times are GMT -5. The time now is 02:41 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration