Search Results

Search: Posts Made By: Subbeh
1,701
Posted By RudiC
You could try with eval. This method should be...
You could try with eval. This method should be deployed with care; you should know EXACTLY what you are evaling as you may end up running unwanted or even malicious code without control of it.
1,701
Posted By Chubler_XL
Are $2 and $3 supposed to be filenames or space...
Are $2 and $3 supposed to be filenames or space separated parameter lists?

Here is one bash solution using the -v option of printf:

#!/bin/bash
function csvdiff {
if [ "$1" == "-s" ] ;...
1,030
Posted By Corona688
Try IFS="" read -r separator
Try IFS="" read -r separator
17,129
Posted By Corona688
uuencode is extremely old, mail clients are...
uuencode is extremely old, mail clients are beginning to not understand it. I would try sending to a different email client first, to make sure it's actually going wrong, rather than just being...
1,261
Posted By Don Cragun
Perhaps ed or ex would be simpler: ed -s file...
Perhaps ed or ex would be simpler:
ed -s file <<-"EOF"
g/Mamma/.-1,.+1d
1,$p
EOF
And, if you want to modify the input file instead of just print the file contents with the specified lines...
4,141
Posted By rbatte1
...and is there a question, comments or just a...
...and is there a question, comments or just a code dump waiting for a miraculous response answering your unexplained issue?
8,143
Posted By jim mcnamara
This is fine - the only issue might be for...
This is fine - the only issue might be for maintenance, someone unfamiliar with sed would have issues learning what the code really does.

In the case where you need to reverse the words in a...
784
Posted By Scrutinizer
Hi, use quotes around the first EOF cat >...
Hi, use quotes around the first EOF
cat > "$1/$2.sh" << "EOF"
#! /bin/bash
ant -q -buildfile $HOME/$3/build.xml $4
...
EOF
4,090
Posted By Corona688
It's a good example of arrays. Whether arrays...
It's a good example of arrays. Whether arrays are actually needed here is the question.

Novice programmers tend to store entire documents:

# Store every line
while read LINE
do
...
2,758
Posted By Scrutinizer
Nice Subbeh. It is better to add parentheses,...
Nice Subbeh. It is better to add parentheses, since some awks regard the comparison as ambiguous:
awk '{print ($1<$2)?$1:$2}' file
or
awk '{print ($1<$2?$1:$2)}' file
9,379
Posted By Corona688
Sorry, that is incorrect. Doing that will...
Sorry, that is incorrect. Doing that will truncate the file before awk is finished reading it, throwing away most of its contents.

Even things like sed -i actually use temporary files to store...
21,451
Posted By Don Cragun
In addition to what has already been said, you're...
In addition to what has already been said, you're not looking for a field separator, you're looking for a field fill character. There are several ways to do this, here are two:
awk...
1,785
Posted By Scrutinizer
Because it would be syntactically incorrect. You...
Because it would be syntactically incorrect. You could however do this:
set -A array $(
cat << EOF
val1
val2
val3
EOF
)
7,905
Posted By elixir_sinari
Elementary. [^#] will match one character which...
Elementary. [^#] will match one character which is not an octothorpe (or hash). So, what you are asking grep to match is one non-hash character (mandatory for the overall pattern to match) at the...
7,905
Posted By Scrutinizer
[^#] means a single character that is not a...
[^#] means a single character that is not a hash-sign.
Why not use:
grep '^2013-12-31'
But perhaps you mean this:
grep '^[^#]*2013-12-31'
2,901
Posted By DGPickett
If you check out sdiff using strace/truss/tusc,...
If you check out sdiff using strace/truss/tusc, you can see where it goes wrong. This tool is very educational, turn on all the local options, and learn! Probably, it does seeks and so gets upset...
1,644
Posted By Scott
Well, it could tell you if, for example, either...
Well, it could tell you if, for example, either function returns an error:


$ cat myScript
Func1() {
return $1
}

Func1 1
retval=$?
Func1 0
echo $(($?|$retval))

Func1 0
retval=$?...
1,644
Posted By Skrynesaver
The double bracket is used in bash for arithmetic...
The double bracket is used in bash for arithmetic expansions. thus $((x|y)) is a bitwise OR of the numeric values in $x and $y
1,644
Posted By bartus11
It is bitwise "OR" operator. Check this link:...
It is bitwise "OR" operator. Check this link: Linux Shell Scripting with Bash > Expressions > Bitwise Operations - Pg. : Safari Books Online...
2,055
Posted By itkamaraj
use set -f $ set -f; for f in $files ;...
use set -f


$ set -f; for f in $files ; do echo $f ; done
/tmp/test/*file1
/tmp/test/*file2
/tmp/test/*file3
/tmp/test/*file4
2,055
Posted By Scott
Well, the set -f option mentioned by...
Well, the set -f option mentioned by elixir_sinari is a quick way.to do that (and it works for me in KSH88 on AIX)
2,055
Posted By elixir_sinari
One way: files=' /tmp/*file1 ...
One way:
files=' /tmp/*file1 /tmp/*file2 /tmp/*file3 /tmp/*file4'
set -f
a=($files)
set +f...
7,333
Posted By jim mcnamara
It is probably a "best practices" convention in...
It is probably a "best practices" convention in your shop. It may not be a best practice in reality.

In bash: typeset, when applied as in your example, prevents parameter substitution from being...
1,249
Posted By pamu
Please check this...
Please check this (https://www.unix.com/shell-programming-scripting/204783-capture-specific-fields-file.html#post302721125)

Just replace s with a[$3] here:)
1,220
Posted By rdrtx1
awk '{x=x+$1};END{printf("%.2f\n", x)}'...
awk '{x=x+$1};END{printf("%.2f\n", x)}' testfile
Showing results 1 to 25 of 39

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