Search Results

Search: Posts Made By: hanson44
6,987
Posted By hanson44
That is correct. Thanks. As I said before, I did...
That is correct. Thanks. As I said before, I did expect adding the extra \ would work, was surprised it did not. I just copied the posted script verbatim, did not see the extra semicolon. Here is the...
6,987
Posted By hanson44
That's for sending the exact input file and...
That's for sending the exact input file and script you are using. That really helped.

I took another look, tried several things, learned it's a sticky wicket, found something that seems to work...
962
Posted By hanson44
$ sed -n -e "s/Date and Time: \(.*\) MST/\1/p" -e...
$ sed -n -e "s/Date and Time: \(.*\) MST/\1/p" -e "s/Number of Records: *//p" input
2013-05-11 12:23:12
000005
1,882
Posted By hanson44
You set the environment variable in...
You set the environment variable in $HOME/.profile or $HOME/.bash_profile or other shell configuration file that your shell is using. Using bash shell, you would add a line saying:
export...
1,294
Posted By hanson44
I read it as "n == 3". But you're right, it's not...
I read it as "n == 3". But you're right, it's not really clear.

If the intent is "n >= 3", then you either:
- Use the scrutinizer shorter solution designed for "n >= 3", or
- Change == 3 to >=...
1,294
Posted By hanson44
Here is a way to do it using awk. $ awk...
Here is a way to do it using awk.
$ awk '{cnts[$1]++} $2 > fld2[$1] {fld2[$1]=$2; fld0[$1]=$0} END {for (key in cnts) { if (cnts[key] == 3) print fld0[key] }}' input3
A 5
B 5
C 10
1,110
Posted By hanson44
Here's how to do it in general: $ cat test.awk ...
Here's how to do it in general:
$ cat test.awk
BEGIN { FS=OFS="," }
{n=0; for (i=1;i<=NF;i++) {($i ~ /(*)/) && n++}}
{ print "Fields: " NF, " Matches: " n}
n == 0 {$NF="OFFLINE"}
n < NF-3...
741
Posted By hanson44
You pass variables from a.sh to b.sh by adding...
You pass variables from a.sh to b.sh by adding the variable after the script name, such as b.sh "$x". You receive variables in b.sh by using $1 for the first variable passed, $2 for the second, etc....
2,013
Posted By hanson44
awk 'NR>1 && !/^\+/{print RS}1 END{print RS}'...
awk 'NR>1 && !/^\+/{print RS}1 END{print RS}' ORS= file1
Should be (using gawk anyway, did not test with other awk versions):
awk 'NR>1 && !/^\+/{print RS}{print} END{print RS}' ORS= file1

$ cat...
2,474
Posted By hanson44
Here is one possible way: ls | grep -v...
Here is one possible way:
ls | grep -v dasd_91197.trc | xargs rm
If more than one file to retain:
ls | grep -v -e dasd_91197.trc -e someother.trc | xargs rm

---------- Post updated at 04:49 AM...
4,909
Posted By hanson44
Here is the input you most recently posted: $...
Here is the input you most recently posted:
$ cat input
2 9647701612350 9647701168456 262 23 1303031257462B0300 1303031259182B0300 92 9647701146402 0
5 ...
Forum: Programming 05-07-2013
1,985
Posted By hanson44
Here's how I would put it. Much of this you...
Here's how I would put it. Much of this you probably already know.

If you declare int n = 4;, then the compiler reserves a special location to store an int value, and stores 4 there. No big deal....
752
Posted By hanson44
I'm not sure what the hadoop command is doing....
I'm not sure what the hadoop command is doing. Anyway, maybe this might work:

SOURCE=/path/to/files/
find "$SOURCE" -type f -mtime -1 -exec cp -v "{}" /usr/path/ \;
Forum: Programming 05-07-2013
1,985
Posted By hanson44
Because arr[0] is exactly the same as *arr ...
Because arr[0] is exactly the same as *arr

In general, arr[i] is exactly the same as *(arr + 1)

This is one of the most difficult and fundamental concepts of C programming. It took me years of...
Forum: Programming 05-07-2013
1,985
Posted By hanson44
Suppose you had "int int_array [12]". Then...
Suppose you had "int int_array [12]". Then "int_array [n]" would be an int.

argv is declared as "char *argv []" So "argv [n]" is a "char *".

"char *" is what "printf %s" expects and what makes...
1,445
Posted By hanson44
$ sed ":a s/^\(.\{120,125\}\) /\10/; T; ba" input...
$ sed ":a s/^\(.\{120,125\}\) /\10/; T; ba" input
A 4175.0 8055.01211 75 1 -2172671 77 45 16 457626.4 2609265.1 131.3 1090 102 1 1T N/A124000015 0.8 ...
1,244
Posted By hanson44
In that case, I would try using rsync to transfer...
In that case, I would try using rsync to transfer the files.

Or, you could create a tar file with files / dirs starting with a-m, transfer it, delete it, then make another for those starting with...
Forum: Programming 05-06-2013
1,167
Posted By hanson44
There are widely used ways to automatically and...
There are widely used ways to automatically and securely log into remote systems using public and private keys that are stored in files. It's been a while, so I don't remember the details, but I used...
24,593
Posted By hanson44
If you want to reverse a string, here is the best...
If you want to reverse a string, here is the best way:
$ echo welcome | rev
emoclew
2,032
Posted By hanson44
I think some of your expected output is...
I think some of your expected output is incorrect. Anyway, try the following.


$ cat test.awk
NR==1 {split ($0, headers); print; next}
{
x=NF; $11=$12="-"
for (i=2; i<x; i++) {
if ($i > 5...
1,141
Posted By hanson44
Well, what can you change? The easiest solution...
Well, what can you change? The easiest solution is:
run_program in="$IN/${sample}_file1.fa $IN/${sample}_file2.fa"
10,918
Posted By hanson44
echo `expr substr $x 1 expr ${#x} - 1` At...
echo `expr substr $x 1 expr ${#x} - 1`

At least one reason your nested substitution does not work is because you only have one set of `` backticks. Regardless of whether you use the older backtick...
4,909
Posted By hanson44
Sure, substr is a function that returns a...
Sure, substr is a function that returns a "substring".

$3 - obviously, that's the field to work on.

0 - starting position. Properly, should have been 1, since awk numbers starting from 1 for...
2,383
Posted By hanson44
Reading a non-cached file, on generic Dell...
Reading a non-cached file, on generic Dell OptiPlex 380:
$ time wc -c 2011.bb
4234978 2011.bb

real 0m0.009s
user 0m0.000s
sys 0m0.004s
2,383
Posted By hanson44
wc -c file will give the file size in bytes.
wc -c file will give the file size in bytes.
Showing results 1 to 25 of 176

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