Search Results

Search: Posts Made By: hanson44
3,337
Posted By hanson44
No. But would not hurt. No. But would not...
No. But would not hurt.

No. But would not hurt.

Yes. Very different.
Forum: What is on Your Mind? 03-19-2013
27,242
Posted By hanson44
I recently joined. I just found it by googling. ...
I recently joined. I just found it by googling.

I think the forum is very good. I've enjoyed it, both for learning new things from some really smart people, and trying to contribute my knowledge....
1,672
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
18,469
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...
18,469
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...
2,538
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...
2,269
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 >=...
2,269
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,955
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...
1,385
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....
29,531
Posted By hanson44
$ cat input hiring,no system,yes hiring,yes...
$ cat input
hiring,no
system,yes
hiring,yes
quota,no
quota,maybe

$ sort input | awk 'NR == 1 {p=$1; next} p == $1 { print $1 " is duplicated"} {p=$1}' FS=","
hiring is duplicated
quota is...
16,030
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 ...
3,727
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...
1,137
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/ \;
5,179
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...
Forum: Programming 05-07-2013
2,943
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....
Forum: Programming 05-07-2013
2,943
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
2,943
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...
Forum: Programming 05-06-2013
1,831
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...
1,568
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...
2,193
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 ...
40,796
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
5,328
Posted By hanson44
There is no hard and fast rule. But from my...
There is no hard and fast rule. But from my experience:

Learn head and tail first, and use them preferably. They are simple and well suited to specific task. uniq, grep and tr are also quite...
3,986
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...
22,746
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...
Showing results 1 to 25 of 176

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