Search Results

Search: Posts Made By: hanson44
6,274
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,274
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...
958
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,860
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,650
Posted By hanson44
awk 'NF && !/#/ {action}' file That would not...
awk 'NF && !/#/ {action}' file
That would not work. It has two problems.

First, it would need to be !/^#/ to mean "do not act on lines that start with #".

Second, the idea was to act on lines...
6,274
Posted By hanson44
I'm not sure why it is not working either. It...
I'm not sure why it is not working either. It "ought" to work. You can probably see the alister and hanson44 solutions are the same, the only difference being whether to assign the pattern to a...
6,274
Posted By hanson44
The pattern within /PAT/ cannot include...
The pattern within /PAT/ cannot include variables. The spacebar fixed pattern is one solution. A more general solution, exactly the way you want it, is as follows:
PAT=X "(15|20|45|70)" Y; if (Z !~...
1,650
Posted By hanson44
awk '/^[^#]/ {print}' file It prints...
awk '/^[^#]/ {print}' file


It prints lines that start with a character that is not #. A blank line does not start with a character. So a blank line is not printed, so the blank line is removed...
2,891
Posted By hanson44
The first two ways don't work, because the first...
The first two ways don't work, because the first $x is expanded. The third also does not work, and is quite confusing. To make it clear and easy to understand, the two best ways to write this are:
...
1,287
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,287
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,147
Posted By hanson44
old="/usr/inter/wat/dat/out" new="/home/trw/sh"...
old="/usr/inter/wat/dat/out"
new="/home/trw/sh"

sed "s/$old/$new/g" file >new_file
I'm afraid that won't work. Try it, it will crash. You have to use a different separator character than / in...
1,101
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...
732
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,002
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,434
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: Solaris 05-08-2013
917
Posted By hanson44
You have several choices: - Use an absolute...
You have several choices:

- Use an absolute path like /home/mydir/script.sh command.

- Put the script in a directory that is part of your PATH, which you can check with echo $PATH and set in...
768
Posted By hanson44
The * is messing things up: $...
The * is messing things up:
$ str1=`hostname`.`date "+%d%m%y%k"`*
I think you mean:
$ str1=`hostname`.`date "+%d%m%y%k"`
3,270
Posted By hanson44
-iname pattern Like -name, but the match is...
-iname pattern
Like -name, but the match is case insensitive.
1,439
Posted By hanson44
You could use \* instead of * for Str1, similarly...
You could use \* instead of * for Str1, similarly escape other metacharacters as needed. I know that's a bother, but certainly doable. Not sure what else to suggest that would work.
$ cat input...
4,730
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,963
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....
747
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,963
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...
1,876
Posted By hanson44
sed '42,$d' infile > outfile Just a suggestion....
sed '42,$d' infile > outfile
Just a suggestion. The above is OK, but it is better in several says to just say head -n 41 infile > outfile
Showing results 1 to 25 of 500

 

Featured Tech Videos

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