Bash $(...) DISPLAYS EVERY COMMAND


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash $(...) DISPLAYS EVERY COMMAND
# 1  
Old 02-01-2016
Bash $(...) DISPLAYS EVERY COMMAND

I use things like this a lot in ksh and bash, but lately bash has been printing the command for every loop:
Code:
... | while read f
do
if [ "$(cmp $f xx/$f 2>&1)" = "" ]
then
 echo Differ "$f"
fi
done

How to prevent this?
# 2  
Old 02-01-2016
Hints: -x or -v as arguments to the shell

So... perhaps you didn't mean to have those arguments set... so it's possible the shell is defaulting to this elsewhere. Or perhaps somebody did something like a "set -x" from the command line. So you can try doing "set -" (set dash) to see if that fixes things.
# 3  
Old 02-01-2016
No, this just applies to the subshell of the (...). Here is another example, with first page of screen output:
Code:
$ (cd GnuCash ; find * -type f|while read f; do  fi [ ! -s ~/GnuCash2/"$f" ]thencp -p "$f" ~/GnuCash2/"$f";continuefid="$(cmp "$f" ~/GnuCash2/"$f" 2>&1)";  if [ "$d" != "" ];  then   echo Differ: "$d";ls -ld "$f" ~/GnuCash2/"$f";  fi; done)2>&1|pg























cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
Differ: ubuntu-DGPickett.gnucash /home/dgp/GnuCash2/ubuntu-DGPickett.gnucash differ: byte 13, line 1
-rw-rw-r-- 1 dgp dgp 1345098 Jan 30 15:04 /home/dgp/GnuCash2/ubuntu-DGPickett.gnucash
-rw-rw-r-- 1 dgp dgp 1347820 Feb  1 13:12 ubuntu-DGPickett.gnucash
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
cmp "$f" ~/GnuCash2/"$f" 2>&1
:

You can see it is a pretty worthless thing to do, too!
# 4  
Old 02-01-2016
Lots of typos in what you had... just to make sure, could you either edit your post or submit correction to clean things up a bit?
# 5  
Old 02-01-2016
Quote:
Originally Posted by cjcox
so it's possible the shell is defaulting to this elsewhere.
I second this. If i remember correctly bash first reads the /etc/bashrc and only then the rc-file in the own $HOME. Might it be that somehow the subshells only use one of these and hence operate with a different configureation than your login shell(s)?

I hope this helps.

bakunin
# 6  
Old 02-01-2016
The
Code:
shopt -q

builtin lets you test which options are in effect. Read this discussion which is too long for display here.

https://www.gnu.org/software/bash/ma...-Shopt-Builtin

....Instead of shooting in the dark. Then you can eliminate set -[some option ] as a problem
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies

2. Shell Programming and Scripting

Cp command works on command line but not in bash

The below command moves all the .vcf files into the directory. cp /home/cmccabe/Desktop/test/vcf/overall/stats/*.vcf /home/cmccabe/Desktop/NGS/annovar When I use a bash wrapper the target.txt gets created but the text files do not get copied. All the paths are the same, but not sure why... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. UNIX for Dummies Questions & Answers

Which of the following command displays your login shell in bash shell?

Options:: A)$shell B)echo $ bash C)echo $ O D)$ O (1 Reply)
Discussion started by: raghugowda
1 Replies

4. Solaris

Last command displays wrong information

Hi am having Solaris10 - Sun-Fire-V890 server, the information displayed by Last command is wrong how do i get this sorted without loosing any datas.. # uptime 12:32am up 20 day(s), 33 min(s), 1 user, load average: 1.54, 1.82, 1.93 # last reboot reboot system boot Sat... (9 Replies)
Discussion started by: Sojourner
9 Replies

5. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

6. AIX

Typing "bash" at the command line spawns two bash processes

Server: IBM p770 OS: AIX 6.1 TL5 SP1 When one of our develoeprs types "bash" on the command line to switch shells, it hangs. For some reason, two bash processes are created....the first bash process spawns a second bash process in the same console, causing a hang. Anyone have any idea what... (2 Replies)
Discussion started by: wjssj
2 Replies

7. AIX

Command last displays wrong hostname

I faced an interesting problem on my AIX servers. When I checked last logins with command last I saw that hostnames are wrong. Let say, I made login from workstation xxxxx and with the command last I saw: root pts/2 yyyyy 5 jan 15:38 still logged in Ping xxxxx and ping... (3 Replies)
Discussion started by: giovanni
3 Replies

8. UNIX for Dummies Questions & Answers

Creating a file that contains output from a command, and then displays itself

hey, I'm trying to create the command that will create a file named user.txt that contains the output of the command cut -d: -f1,5 /etc/passwd, and displays itself afterwards. I don't know how to bridge cat > user.txt with cut -d: -f1,5 /etc/passwd, or how display it afterwards. Any help would... (2 Replies)
Discussion started by: raidkridley
2 Replies

9. HP-UX

Dual Displays HP-UX 10.20

Hello All! Where I work we have C3600's that have a video cards that have both DVI and Regular RBG type monitor ports on them. My question is: is it possible to spread my desktop across two monitors that are plugged into the one card much like you can do with NVIDIA software like NVIEW for... (0 Replies)
Discussion started by: giftedone
0 Replies

10. UNIX for Dummies Questions & Answers

Dual Displays

I have a TV and a monitor hooked up to my box. Right now the system is displaying all the information on the TV instead of the monitor, obviously I want to switch this, as the TV is very impracticle for everything other than watching movies. I thought I remembered a command I used to use that... (2 Replies)
Discussion started by: Synbios
2 Replies
Login or Register to Ask a Question