LinuxQuestions.org
Help answer threads with 0 replies.
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 01-05-2012, 11:03 AM   #1
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Rep: Reputation: 16
Linux .... bash-v what is it?


I have been apending the pipe bash -v to the end of my scripts. It seems to pipe whatever is printed out by the command into an executable something.
I am not sure how it works or what it is - looked on the interwebs adn man pages and could not find a thing.

It is a great tool

Code:
casper@casperbox:~$ ps auxwww   | grep chrome | awk '{print "kill -9 "$2}'| bash -v
kill -9 1235
bash: line 1: kill: (1235) - No such process
kill -9 10633
kill -9 13854
kill -9 20354
kill -9 20358
kill -9 20360
kill -9 20362
kill -9 20886
kill -9 23051
kill -9 23144
kill -9 23302
kill -9 28158
kill -9 29787
kill -9 29878
kill -9 30145
kill -9 31524
 
Old 01-05-2012, 11:11 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hello,

The -v just means verbose; Using "bash -v," it will print each command to STDOUT before executing the command(s). For a reference/manual, see here - http://tldp.org/LDP/abs/html/options.html

Cheers,

Josh
 
1 members found this post helpful.
Old 01-05-2012, 06:08 PM   #3
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Original Poster
Rep: Reputation: 16
thank you for the refreence - piping commands into a bash -v is a kick a$$ feature.
 
Old 01-05-2012, 06:22 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Actually, that will invoke a new instance/shell of bash.
If you want to see what's going on in a current script, use
Code:
set -v

#OR
#more detail
set -xv
inside your script
 
Old 01-05-2012, 06:56 PM   #5
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by chrism01 View Post
Actually, that will invoke a new instance/shell of bash.
If you want to see what's going on in a current script, use
Code:
set -v

#OR
#more detail
set -xv
inside your script
Hmmm.... So I'm wrong? I thought it was strictly for verbose mode.
 
Old 01-05-2012, 07:08 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Yeah, '-v' =verbose, but 'bash' is still a cmd that invokes a new (sub-)shell.
Because its at the end of a pipe (in this instance) you don't notice it
 
Old 01-05-2012, 07:17 PM   #7
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Oh I did! I was just confused on your context and wording of how you said that. All is good!

Cheers,

Josh
 
Old 01-05-2012, 11:04 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Ah, ok sorry about the confusion. I was trying to say to the OP that you can use that switch inside a script, rather than invoking a new sub-shell
 
Old 01-06-2012, 12:17 AM   #9
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Oh ok, I understand now.
 
Old 01-07-2012, 05:05 PM   #10
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Original Poster
Rep: Reputation: 16
what would i use if i did not want the executed commands to out put to the console -
 
Old 01-07-2012, 05:22 PM   #11
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Just take away the -v out of the snippet of code. Alternatively, you could run the following:
Code:
code 1>/dev/null 2>/dev/null
Cheers,

Josh
 
Old 01-07-2012, 07:43 PM   #12
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
To disable an option with set change the minus to a plus.

Code:
set -v	#enable verbosity
set +v	#disable verbosity
This, along with the -x option, is particularly useful in scripts for debugging.

Note that most of the set options correspond to options you can use when invoking bash directly. "bash -v" runs an instance of bash with verbosity enabled (you can add it to the shebang at the top of a script, for example). Or you can run bash with no options first, then use set -v separately to do the same thing.

And as always, the details are in the man page. Start with the OPTIONS section at the top, then scroll down to the SHELL BUILTIN COMMANDS and read the entry for set.
 
  


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
Bash problem : -bash: [: /bin/bash: unary operator expected J.A.X Linux - Software 1 09-22-2011 05:52 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

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

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