Re: ReadLines and Substraction

2011-03-14 Thread pk
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 line

Re: Mapfile callback access to current line

2010-05-04 Thread pk
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

Re: Variable getopts lost

2010-02-23 Thread pk
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.

Re: FWD: About Bash Script

2010-02-16 Thread pk
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 ...

Re: FWD: About Bash Script

2010-02-16 Thread pk
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.

Re: Is there a special variable for the directory where the script is in?

2010-02-11 Thread pk
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:

Re: best way to test for empty dir?

2009-12-11 Thread pk
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...

Re: best way to test for empty dir?

2009-12-10 Thread pk
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$(echo $1/*$2) =

Re: Fullscreen unchecking show menubar.

2009-12-07 Thread pk
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

Re: bash is not capable of comparing of strings and real numbers

2009-12-07 Thread pk
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 really speak as

Re: output redirection with process substitution asynchronous?

2009-12-06 Thread pk
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.

Re: output redirection with process substitution asynchronous?

2009-12-04 Thread pk
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: 2 Friday,

Re: functions can be created with dotted name but not removed

2009-12-04 Thread pk
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 unset f

Re: Doubt on variable $

2009-12-01 Thread pk
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 anyone

Re: IFS handling and read

2009-11-30 Thread pk
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 parts

Re: IFS handling and read

2009-11-30 Thread pk
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 is in a subshell environment

Re: Use of pipe in $( filename | program) returns null

2009-11-28 Thread pk
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 Fix: Either fix

Re: printf %q and $'...'

2009-11-25 Thread pk
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 answers

Re: printf %q and $'...'

2009-11-25 Thread pk
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, imho, there's

Re: for i in {1..100000...

2009-11-12 Thread pk
Antonio Macchi wrote: what's the rasonable limit in using this compact contruct, after which the for (( i=0; i1000...; 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: cannot

Re: qwerty

2009-11-12 Thread pk
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 version

Re: triggering of ERR trap differs between bash 3.2.39 4.0.28

2009-11-08 Thread pk
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 does not happen

Re: doing simple math in bash :: prb with leading zero

2009-09-01 Thread pk
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 hexadecimal.

Re: how to keep newlines in ``

2009-08-26 Thread pk
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

Re: time seg fault

2009-07-23 Thread pk
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 other

Re: RFE: zero prefixed expansion, e.g. {01..02} - 01 02

2009-06-06 Thread pk
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}.bar

Re: Regex matching oddity (bug, or 'unexpected feature' or...?)

2009-05-28 Thread pk
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 string

Re: Regex matching oddity (bug, or 'unexpected feature' or...?)

2009-05-28 Thread pk
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 during 3.2 (too lazy to check now

Re: Is there any mutex/semaphore mechanism in shell scripts?

2009-05-21 Thread pk
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 FUNCTION_2

Re: big 'list' consumes all memory

2009-04-16 Thread pk
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. There

Re: Question

2009-04-03 Thread pk
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

Re: order of redirections

2009-03-02 Thread pk
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 21 directs both standard output (file descriptor 1) and standard error

Re: {# - strange behavior

2009-02-23 Thread pk
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 byte was

Re: is it a bug? (little script)

2008-10-05 Thread pk
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 90 while read dirname do echo $dirname # if I wait, exits!!! read -t 2 -p press enter... 09 done test_fifo exec 9- exit 0 You know

Re: inconsistent treatment of backslash-bang

2008-07-22 Thread pk
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]:~ echo hi

Re: inconsistent treatment of backslash-bang

2008-07-18 Thread pk
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 interactively. On my system, I get

Re: inconsistent treatment of backslash-bang

2008-07-16 Thread pk
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 double quotes.

Re: builtin printf not printing unicode characters?

2008-05-13 Thread pk
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 '\u212b\n' \u212b Am I doing something wrong here? The `\u

Re: for ... in ... do ignores escape characters

2008-04-18 Thread pk
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

Re: for ... in ... do ignores escape characters

2008-04-18 Thread pk
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