Skip to content
Advertisement

Tag: shell

How do I execute javascript programs from the Linux shell?

I would like to execute my javascript programs with the Rhino shell without making the first line #!/bin/sh. ‘#’ isn’t a comment character in javascript. I also don’t want to have to have a .js extension. Is this possible? I remember reading something a long while about a method of making java programs to run without an explicit interpreter. Google

Force a shell script to fflush

I was wondering if it was possible to tell bash that all calls to echo or printf should be followed up by a subsequent call to fflush() on stdout/stderr respectively? A quick and dirty solution would be to write my own printf implementation that did this and use it in lieu of either built in, but it occurred to me

What is the difference between “source script.sh” and “./script.sh”?

What is the difference between source <script> and ./<script>? Answer source script.sh runs the script within the current process, thus all variable assignments are preserved as variables even after the script finishes (and don’t have to be explicitly export’d). ./script.sh just runs the script in a subprocess, and any variables which are assigned disappear after the script is done.

BASH: how to perform arithmetic on numbers in a pipe

I am getting a stream of numbers in a pipe, and would like to perform some operations before passing them on to the next section, but I’m a little lost about how I would go about it without breaking the pipe. for example Would you have any ideas on how to make something like this work? The actual operation I

Parsing result of Diff in Shell Script

I want to compare two files and see if they are the same or not in my shell script, my way is: Basically, if they are the same ${diff_output} should contain nothing and the above test would evaluate to true. But when I run my script, it says [: too many arguments On the if [….] line. Any ideas? Answer

Advertisement