Search Results

Search: Posts Made By: Michael Stora
3,497
Posted By Chubler_XL
Some more playing around and I'm also seeing the...
Some more playing around and I'm also seeing the \r characters being truncated - BINMODE seems to help with GNU awk:

awk '{gsub(/\n/,"|"); gsub(/\r\|/,"\n"); print}' RS='' BINMODE=1 file
4,908
Posted By Scrutinizer
Try: awk '{gsub(/"/,q,$NF); gsub("^" q "|" q...
Try:
awk '{gsub(/"/,q,$NF); gsub("^" q "|" q "$","\"",$NF)}1' FS=, OFS=, q=\' file
8,896
Posted By Chubler_XL
You can read about quite a few of them here Xterm...
You can read about quite a few of them here Xterm Control Sequences (http://www.xfree86.org/4.7.0/ctlseqs.html)
8,896
Posted By wisecracker
This worth a try if it is rows and columns. ...
This worth a try if it is rows and columns.
#!/bin/bash
# Set window size down to 66 cols x 32 rows, not tested on mintty but worth a try...
printf "\x1B[8;32;66t"
# Write into the title bar;...
3,741
Posted By Don Cragun
First, you have an extra dollar sign (shown in...
First, you have an extra dollar sign (shown in red above) that shouldn't be there.

Second: your default if empty string is misleading. With the form argument=${parm-word}, word is assigned only...
3,741
Posted By RudiC
But - hasn't that been shown to you in posts #2...
But - hasn't that been shown to you in posts #2 and #3?
awk -vb=XXX 'BEGIN {a=b?b:"Default"; print a}'
XXX
awk 'BEGIN {a=b?b:"Default"; print a}'
Default
4,268
Posted By neutronscott
Well I won't pick apart at your code too much...
Well I won't pick apart at your code too much more then. ;)

To answer the question on whitespace, awk shouldn't be messing with them aside from the default FS being equivalent to...
3,741
Posted By Chubler_XL
Well you could us the ? operator like this: ...
Well you could us the ? operator like this:

argument=length($1) ? $1 : "default if empty"

or like this:

argument=$1~"^$" ? "default if empty" : $1
3,554
Posted By disedorgue
Hi, ternary operator is: Condition ? one and...
Hi,
ternary operator is:
Condition ? one and only one true expr : one and only one false expr
you must have false expr also:
hour >= 12? amPm=" PM" : amPm=" AM"
hour >= 12? hour = hour - 12 : 0...
3,394
Posted By jlliagre
Ireland is currently UTC+1 while Phoenix is UTC+7...
Ireland is currently UTC+1 while Phoenix is UTC+7 so the date displayed is correct.
3,394
Posted By jlliagre
It is unclear why you want to convert your local...
It is unclear why you want to convert your local time to the time in Ireland. If what you really want is to display the current time in Ireland, the proper command would be:

TZ="Europe/Dublin" date
3,394
Posted By Chubler_XL
Try: $ TZ="Europe/Dublin" date Mon, Apr...
Try:

$ TZ="Europe/Dublin" date
Mon, Apr 13, 2015 11:27:51 PM
1,128
Posted By Scrutinizer
How do you know it does not work? If you are...
How do you know it does not work? If you are printing the content of the variable dump that also needs to be quoted:
echo "$dump"
1,299
Posted By Chubler_XL
It gets the value of the variable "expand" and...
It gets the value of the variable "expand" and treats this as a variable name and the fetches its value.

So
$ t=5
$ x=t
$ y=x
$ echo ${!x}
5
$ echo ${!y}
t
1,299
Posted By Chubler_XL
I'd suggest not using eval at all, just code your...
I'd suggest not using eval at all, just code your own allowed expansions e.g.:

expand='$RANDOM'
[ ${expand:0:1} = "$" ] && {
expand=${expand:1}
expand=${!expand}
}

So here we support...
2,237
Posted By neutronscott
since you're using bash I'd say <<< "$string" is...
since you're using bash I'd say <<< "$string" is a much better option than < <(echo "$string").


$ IFS=: read -raa <<< "$PATH"
$ declare -p a
declare -a a='([0]="/home/mute/bin"...
2,270
Posted By bakunin
What you describe is a (very simple) parser. The...
What you describe is a (very simple) parser. The following sketch roughly does what you want, you will want to put it into a function in you script. I wrote it for ksh initially, so you will probably...
2,270
Posted By Chubler_XL
Love the f_Parse function Bakunin. It got me...
Love the f_Parse function Bakunin. It got me thinking about a quoted_read function that works like read but supports quoted strings so I could call it like this

test='one two three four five...
2,270
Posted By Corona688
It's not whether it "likes" it or not. It's...
It's not whether it "likes" it or not. It's because of the order shell processes a statement.

The temporary IFS assignment only becomes valid when the statement is executed -- but in order to...
2,237
Posted By Corona688
And where do you get this string? Perhaps it...
And where do you get this string? Perhaps it could be parsed in the first place instead of later.

Actually, I didn't know that either.

That's something totally different from what I was...
2,237
Posted By Corona688
It has to, to avoid deadlocks. Which runs first,...
It has to, to avoid deadlocks. Which runs first, the echo or the read? Will either of them hang, waiting for the other? Make them independent and it doesn't matter.
2,237
Posted By Scrutinizer
That is not because of read, but because the...
That is not because of read, but because the right hand side of the pipe is executed in a subshell in bash and some other bourne type shells. It works in ksh though...

--
Note that IFS=":"; read...
2,237
Posted By Corona688
Consider what happens when you do a | echo a...
Consider what happens when you do a |

echo a b c | some program

If "some program" were cat, would it change any memory or variables in your current shell? Of course not, it doesn't have access...
3,489
Posted By RudiC
Try echo -e "hello\ngoodbye\n####\ntesting" |...
Try echo -e "hello\ngoodbye\n####\ntesting" | while read line && [ "$line" != "XXXX" ]; do echo "$line"; done
hello
goodbye
####
testing
2,714
Posted By itkamaraj
xargs -0 ( gnu xargs supports this )
xargs -0 ( gnu xargs supports this )
Showing results 1 to 25 of 53

 
All times are GMT -4. The time now is 03:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy