yetcom wrote:
> Hello Everyone,
>
> I have an issue regarding the bash. I have 2 different files and each
> of them involves some float point numbers for each lines. I want to
> subtract each line then put all the results into a file. The first
> line float number will be subtract with the first
Binarus wrote:
> The script
>
> echo 'line1' > file
> echo 'line2' >> file
> RESULT=$(cat file)
> echo "$RESULT"
>
> gives the following output:
>
> line1
> line2
>
> I don't understand why: the command substitution $(cat file) is not
> within double quotes, so word splitting should be applied
DennisW wrote:
> Mapfile would be that much more powerful if the callback function had
> access to the current line. Is there any chance this might be added in
> the future?
Can't answer directly on this, but it looks like the gateway between this
group and the mailing list hasn't worked for a l
Is the =~ operator supposed to recognize \n in patterns? Example:
$ a='abc
def'
$ if [[ $a =~ c\nd ]]; then echo ok; fi
The above produces no output (I've tried using \\n, \\\n too), while using a
literal newline works:
$ if [[ $a =~ c$'\n'd ]]; then echo ok; fi
ok
Is that expected behavior o
Javier Montoya wrote:
> Dear all,
>
> I have a several directories with *.jpg images. The image files are
> named as ascending numbers and I would like to retrieve the lowest and
> largest image number in each directory. An example of the content of a
> directory is given below:
> /bla/bla/bla/di
Peng Yu wrote:
> My grep is aliased to "grep --color=auto".
>
> I then use grep "", where is a tab character. But the
> result is not colored. How to make the tabs colored?
GREP_COLORS='ms=07;31' grep ...
man grep, and wrong mailing list.
Daniel Bunzendahl wrote:
> My question wasn't fokused on my wrong script. I think there is something
> wrong or limited by the System...
> Maybe you can give me a tip I should search for...
You've got it already...either invoke the script with its name (not through
bash), or use bash -- etc.
Curtis wrote:
> if [! -e b.txt];
Please note that should literally be
if [ ! -e b.txt ];
NOT
if [! -e b.txt];
Try running the latter and you'll get errors.
Curtis wrote:
> Here's what I have but i'm getting some errors
>
> #!/bin/bash
>
>
> if ! (-e b.txt);
ITYM
if [ ! -e b.txt ]; then
...
Peng Yu wrote:
> $0 gives the file name of the script. I could use several shell
> command to get the directory where the script is in. But I'm wondering
> if there is an easy-to-use variable that refers to the directory where
> the script is in?
See this page:
http://mywiki.wooledge.org/BashFAQ
Marc Herbert wrote:
> For purists, does this one works even better?
>
> is_file3()
> {
> for f
> do
> [ -e "$f" -o -L "$f" ] && return
> done
> return 1
> }
You might also want to enable "dotglob" to catch hidden files...
pk wrote:
>> is_file()
>> {
>> for f
>> do
>> [ -f "$f" ] && return
>> done
>> return 1
>> }
>>
>> is_file /path/to/dir/* || echo empty
>
> This fails if the directory contains a file ca
Chris F.A. Johnson wrote:
> On Thu, 10 Dec 2009, Marc Herbert wrote:
>
>> Does anyone know a more elegant way to check for file existence?
>> Something that does not fork a subshell. And is also more readable
>> maybe. And is obviously not much longer.
>>
>> empty_dir()
>> {
>> test "x$(ech
phani krishna jampala wrote:
> bash is not capable of comparing of strings ( imean interms of lessthan or
> greater than etc)
It is, if you use [[ ]]
a="abcd"
b="bcde"
if [[ "$b" > "$a" ]]; then
echo "$b is greater than $a"
fi
> and real numbers ( the float values).
True, but I can't real
Rodney Varney III wrote:
> Repeat-By:
> View, fullscreen, view, uncheck show menubar
Where are you seeing any menubar in bash?
You're probably referring to the terminal in which bash is running. In that
case, it's likely that it's a problem with the specific terminal
implementation (eg gnome te
Marc Herbert wrote:
>> pjodrr wrote:
>> It would be nice if you explained what it is you're attempting to do,
>> rather than ask for a solution for what you're thinking would do that.
>
> To be honest that is the first thing he (tried to) do:
>
> pjodrr wrote:
>> how can I prefix every line of o
pjodrr wrote:
> in my original example the "seq 4" runs in the current shell
> while here the command runs in a subshell.
It would be nice if you explained what it is you're attempting to do, rather
than ask for a solution for what you're thinking would do that.
pjodrr wrote:
> Hi
>
> On Dec 4, 7:58 pm, pk wrote:
>> What's wrong with
>>
>> seq 4 | while read line; do echo "$(date): $line"; done
>
> it creates a subshell
uh...where do you think your original
>(while read line; do echo "$(date): $line"; done)
runs?
Michael O'Donnell wrote:
> A bash function with a dot in its name can be created and used with no
> problems but cannot be removed - the "unset" command chokes on the name.
>
>
> Repeat-By:
>
> This sequence yields the expected results:
>
> function f() { echo $FUNCNAME ; }
> f
> u
pjodrr wrote:
> Hello,
>
> how can I prefix every line of output of some command with a
> timestamp? I thought like this:
>
> $ exec 3> >(while read line; do echo "$(date): $line"; done)
> $ seq 4 >&3
> Friday, December 4, 2009 4:20:29 PM MET: 1
> $ Friday, December 4, 2009 4:20:29 PM MET:
visco wrote:
> Could anyone tell me what is the purpose of $<
>
> I found it in a Makefile as follows
> $(CXX) $(CXXFLAGS) -c $< -o $@
That's not a bash variable. It's a Makefile variable.
http://www.gnu.org/software/make/manual/make.html#Automatic-Variables
> Also it would be nice if any
pk wrote:
>> Because that's POSIX' choice?
>
> No, POSIX allow either behavior. In fact, it allows any behavior ranging
> from running all parts in their own subshells, to running all parts in the
> current shell.
"...each command of a multi-command pipeline
Marc Herbert wrote:
> Chris F.A. Johnson a écrit :
>>Why should it be the last element of a pipeline that is executed in
>>the current shell and not the first?
>
>
> Because that's POSIX' choice?
No, POSIX allow either behavior. In fact, it allows any behavior ranging
from running all
Chet Ramey wrote:
> r...@saturn.syslang.net wrote:
>
>> Description:
>> use of $(< filename | program) does not work. It either should or it
>> should be properly documented. The problem also happens on bash4.
>>
>> Repeat-By:
>>
>> qq=$(< /etc/passwd | grep sys)
>> echo $qq
>> # result is null
Antonio Macchi wrote:
> but...
>
> $ printf one$'\x00'two\\n
>
> +-+-+-+-+-+-+--+
> |p|r|i|n|t|f|\0|
> +-+-+-+-+-+-+--+
>
> +-+-+-+--+-+-+-+--+--+
> |o|n|e|\0|t|w|o|\n|\0|
> +-+-+-+--+-+-+-+--+--+
>
> so the output should be "one", and stop here!
>
> but the real output is
> onetwo
>
> so, i
Antonio Macchi wrote:
>> $ printf "\x00\n" | cat -A
>> ^@
>
> it works, so why...
>
> $ printf $'\x00' | cat -A
> $
Read carefully ALL the answers you've been given. The short version is that
$'\x00' is interpreted by bash itself, while '\x00\n' is interpreted by
printf only. But DO READ the
Antonio Macchi wrote:
> I'm on error, I know... but, in your bash-ref guide you don't explain a
> lot printf
>
> and in man printf don't do it too...
>
> from man printf
> -
> NOTE: your shell may have its own version of printf, which usually
> supersedes the versio
Antonio Macchi wrote:
> what's the rasonable limit in using this "compact" contruct, after which
> the for (( i=0; i<1000...; i++ )) became better?
You didn't even bother trying eh?
$ for i in {0..10}; do echo $i>/dev/null; done
bash: xmalloc: ../../../bash/lib/sh/stringvec.c:40: cann
Amit Dor-Shifer wrote:
> I've the following script:
>
> set -eE
> on_error() { echo ERROR ERROR; }
> trap on_error ERR
>
> if [ -n "$(echo $1 |grep a)" ];then
>echo "input contains 'a'"
> fi
>
> When executed under bash-4, on_error is evaluated as part of the
> expression in the 'if'. This
ken wrote:
> This is what I get on Linux running on an i686.
>
> Bash should be smart enough to know that 09 = 9
> -- and it does sometimes, but not all the time.
> Surprise!!
>From the bash manual:
"Constants with a leading 0 are interpreted as octal numbers. A leading 0x
or 0X denotes hexade
Sam Steingold wrote:
> this:
> foo=`ls`
> echo $foo
> will print files in one line even though ls prints them with newlines.
> is there a way to preserve newlines in the above echo?
> thanks.
echo "$foo"
rjustinwilli...@gmail.com wrote:
> Hi all
>
> I have, on a 64-bit system an issue with time hanging. I've installed
> multiple versions, one at a time, and gotten the same results on each
> version.
>
> If I use tcsh, instead of bash, time works.
>
> With bash 3.17, I got a seg fault; with the
On Friday 5 June 2009 20:28, Till Maas wrote:
> Aloas,
>
> I often need the results of expansion like {01..10} to be prefixed with
> zeros, currently I always need to have two expansions, e.g.
>
> cat foo0{1..9}.bar foo{10..23}.bar
>
> It would be nice if I could use e.g.
>
> cat foo{01..23}.b
On Thursday 28 May 2009 22:38, pk wrote:
> Yes, if the second argument is quoted, it's treated as a literal string.
> If you want the regex behavior, you should not quote it:
>
> if [[ "$Var" =~ +([:digit:]) ]]; then .
>
> That behavior changed at some point
On Thursday 28 May 2009 21:58, Linda Walsh wrote:
> But when I used regex pattern matching in the if, the spaces around the
> operator
> caused a failure in matching. I.e.:
> if [[ "$Var"=~"+([:digit:])" ]] ; then ...
> worked.
"worked" in the sense that [[ .. ]] evaluated a single argument: the
On Wednesday 20 May 2009 21:34, jjjaime wrote:
>
> I would like to execute some functions in parallel, but the last method
> has to wait until the first 2 functions have finished.
>
> The script is:
>
> FUNCTION_1() {
> ...
> }
> FUNCTION_2() {
> ...
> }
> FUNCTION_3() {
> ...
> }
> FUNCTION_1
On Thursday 16 April 2009 11:11, Mart Frauenlob wrote:
> for i in $(seq 0 15755500); do echo $i; done
> -bash: xrealloc: ../bash/subst.c:512: cannot reallocate 182209024 bytes
> (0 bytes allocated)
>
>
> ok, thesis looks confirmed...
> I'm no C programmer, but I try to think logically about it.
On Friday 3 April 2009 03:33, Brandon F wrote:
> When I do traceroute in bash I am always getting
> 12-215-11-193.client.mchsi.com as the third or fourth site. I want to know
> how to clear this from my route list. So it will bounce off of a differant
> site. Thank you.
traceroute | sed '/12-215-
On Monday 2 March 2009 23:34, lehe wrote:
>
> Hi,
> I have some questions about the paragraph in Bash Reference on
> redirections: "Note that the order of redirections is significant. For
> example, the command
> ls > dirlist 2>&1
> directs both standard output (file descriptor 1) and stand
On Monday 23 February 2009 07:31, Antonio Macchi wrote:
>>
>> Yes, it's ok. Posix says that printf field widths are specified in
>> number of bytes.
>>
>
> I've never red nothing about POSIX,
You should, especially if posting here something like that.
> but imho, in the past, "char" and
>
On Sunday 5 October 2008 17:17, Antonio Macchi wrote:
> #!/bin/bash -e
>
> trap "rm test_fifo" 0
> mkfifo test_fifo
>
> ls / > test_fifo &
>
> exec 9<&0
>
> while read dirname
> do
>echo $dirname
>
># if I wait, exits!!!
>read -t 2 -p "press enter..." 0<&9
> done < test_fifo
>
>
On Wednesday 23 July 2008 14:46, Lawrence D'Oliveiro wrote:
>> In which way is that wrong?
>
> Maybe not:
>
> [EMAIL PROTECTED]:~> set +H
> [EMAIL PROTECTED]:~> echo "y"
> y
> [EMAIL PROTECTED]:~> echo "\y"
> \y
> [EMAIL PROTECTED]:~> echo y
> y
> [EMAIL PROTECTED]:~> echo \y
> y
>
> That still
On Tuesday 22 July 2008 13:38, Lawrence D'Oliveiro wrote:
> And even with the specialness of bang turned off, it still doesn't work
> right:
>
> [EMAIL PROTECTED]:~> set +H
> [EMAIL PROTECTED]:~> echo "hi there!"
> hi there!
> [EMAIL PROTECTED]:~> echo "hi there\!"
> hi there\!
> [EMAIL PROTECTED
On Friday 18 July 2008 07:35, Lawrence D'Oliveiro wrote:
> pk wrote:
>
>> This is documented in man bash, and only happens in interactive shells
>> (not scripts).
>
> I just tried putting my six cases into a script, and I get exactly the
> same sort of output as
On Wednesday 16 July 2008 04:47, Lawrence D'Oliveiro wrote:
> Description:
> In all contexts in which a character "X" has special meaning to bash, it
> should be possible to insert that character literally by writing "\X".
> This fails in one case: where "X" is "!", and the context is inside doubl
On Tuesday 1 July 2008 09:51, Pierre Gaston wrote:
> 2008/7/1 pk <[EMAIL PROTECTED]>:
>> On Tuesday 1 July 2008 05:22, Chris F.A. Johnson wrote:
>>
>>> var=${var%.}
>>
>> ITYM
>>
>> var=${var%'
>> .'}
>
> that would defe
On Tuesday 1 July 2008 05:22, Chris F.A. Johnson wrote:
> var=${var%.}
ITYM
var=${var%'
.'}
On Sunday 11 May 2008 04:16, Chet Ramey wrote:
> pk wrote:
>> The man page says that bash builtin printf supports the standard
>> printf(1) formats. But it seems that \u is not working:
>>
>> $ /usr/bin/printf '\u212b\n'
>> Å
>> $ printf '
The man page says that bash builtin printf supports the standard printf(1)
formats. But it seems that \u is not working:
$ /usr/bin/printf '\u212b\n'
Å
$ printf '\u212b\n'
\u212b
Am I doing something wrong here?
I see the same behavior with
GNU bash, version 3.2.13(1)-release (i486-pc-linux-
On Friday 18 April 2008 14:02, Dave Rutherford wrote:
> Quotes or escapes in the output of the `` are input to the shell rather
> than shell syntax, so won't be interpreted. You just need to quote more.
>
> $ foo () { echo sony; echo apple; echo hewlett packard; }
>
> Now note the difference be
On Friday 18 April 2008 14:02, Dave Rutherford wrote:
> Quotes or escapes in the output of the `` are input to the shell rather
> than shell syntax, so won't be interpreted. You just need to quote more.
>
> $ foo () { echo sony; echo apple; echo hewlett packard; }
>
> Now note the difference be
51 matches
Mail list logo