Visit The New, Modern Unix Linux Community

Search Results

Search: Posts Made By: krishmaths
4,447
Posted By MadeInGermany
Supposed you only show $5 it is awk '{gsub(",",...
Supposed you only show $5 it is
awk '{gsub(",", "", $5); sum+=$5} END{print sum}' mylogfile.logThe gsub() returns the number of performed substitutions, not the result string. The result is stored...
Forum: What is on Your Mind? 12-28-2018
312
Posted By Neo
Holiday Thoughts for the End of 2018
Happy Holidays.

Here are my randoms thought at the end of 2018 in no particular order.

You Are Truly Blessed

IT people are lucky. We get to use our brains extensively to solve complex and...
798
Posted By RavinderSingh13
Hello krishmaths, Could you please try and...
Hello krishmaths,

Could you please try and let me know if this helps you. Let's say following is the Input_file.

cat Input_file
A~B CDR~rsbkjdewdj @!!!~deiiugewiuewn
Then following is the...
798
Posted By RavinderSingh13
Hello krishmaths, As you haven't shown us...
Hello krishmaths,

As you haven't shown us the complete requirement here so little difficult to say how you wanted to use these 50 variables. But wanted to highlight here for these kind of...
1,362
Posted By Corona688
This may open other holes if not done carefully...
This may open other holes if not done carefully however (who is allowed to create files there?)
1,362
Posted By Peasant
Make a logic inside your script if a certain user...
Make a logic inside your script if a certain user touches a file in $SOMEDIR/stop.file the process you started will stop looping and exit gracefully.

This way you can avoid sudo and privilege...
1,362
Posted By vbe
Its not that easy ( doing something simple...),...
Its not that easy ( doing something simple...), normally you would lauch that sort of stuff using a share account that is not personnel, local to that box that the ones who can use it have the...
2,203
Posted By alister
The for-in-loop should not be used. The OP wants...
The for-in-loop should not be used. The OP wants to preserve the order of the list, buti in a is not guaranteed to preserve order.

awk '{sum+=$2; a[NR]=$1} END{for (i=1; i<=NR; i++) {print...
4,758
Posted By bakunin
Maybe i can clear this up: Originally, UNIX...
Maybe i can clear this up:

Originally, UNIX commands had only one-character options, some of which could take an argument. The options were introduced with a dash ("-") to distinguish them from...
3,124
Posted By Corona688
Almost nobody has dos2unix, but tr -d '\r' <...
Almost nobody has dos2unix, but tr -d '\r' < inputfile > fixedfile will work anywhere.
846
Posted By bakunin
Yes and no. I think you are missing the point,...
Yes and no. I think you are missing the point, though. Programs are read like onions, peeling layers of loops off. Anyway, the script is poorly written and you should understand that, as we go along....
1,527
Posted By rdcwayx
so what's the reason to set another array b? ...
so what's the reason to set another array b?
awk '{a[$0]++} END{for(i in a){if (a[i]==1) {print i}}}' infile
1,119
Posted By MadeInGermany
@krishmaths: test wants = not == And the...
@krishmaths:
test wants = not ==
And the variable preset can happen once when placed just before the loop
yes="n"
until [ "$yes" = "y" ]
13,235
Posted By Jotne
awk ' /pattern/ {print a} {a=$0}' ...
awk '
/pattern/ {print a}
{a=$0}'

Running on a file:
Line1: Does it contain "pattern", yes print a (here a will be empty), no continue
a=Line1
Line2: Does it contain "pattern",...
738
Posted By alister
Your analysis is incorrect. -name only...
Your analysis is incorrect.

-name only matches against a file's name (the basename of a multi-component pathname). There are two characters that are forbidden in UNIX filenames: / (which is...
6,922
Posted By Don Cragun
I know that you asked for a sed solution, but ed...
I know that you asked for a sed solution, but ed is well suited to something like this and only needs to be invoked once to do it. This was tested using a Korn shell, but will work with any shell...
854
Posted By Jotne
First: No need to cat the file to awk correct...
First:
No need to cat the file to awk
correct awk '{print }1' file
This will print every line two times.

awk has this format
test {action}
this can be repeated
test {action} test {action}...
1,555
Posted By Scrutinizer
Thanks that is good to know. I did some more...
Thanks that is good to know. I did some more tests with several versions of awk on various platforms:
awk -F"|#|" '{print $2}' file
Indeed it works on AIX. It also works with /usr/xpg4/bin/awk on...
2,026
Posted By vidyadhar85
Find will accept multiple pattern in below way ...
Find will accept multiple pattern in below way


find . -name "*log.gz" -o -name "*txt.gz"
684
Posted By anbu23
$ echo Jun | awk ' {...
$ echo Jun | awk ' { printf("%02d",int(index("JanFebMarAprMayJunJulAugSepOctNovDec",$1)/3)+1) } '
06
1,522
Posted By pamu
I believe awk does support length function.. ...
I believe awk does support length function..

try

function calcmaxlen
{
awk -v POS="$1" '{if(length($POS)>max){max=length($POS)}}END{print max}' $HOME/input.dat
}
1,693
Posted By Skrynesaver
echo $1 |egrep...
echo $1 |egrep '^(Jan|Feb|Mar|Apr|may|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$' || echo "Invalid Month entered";
1,693
Posted By hergp
If your shell is halfway current, this should...
If your shell is halfway current, this should work without calling external commands:


if [[ $1 != @(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ]]
then
echo "Invalid input. Should be...
681
Posted By Corona688
If you login to a local terminal, you talk to...
If you login to a local terminal, you talk to /bin/login, if you login with sshd it goes its own way, but these days everything talks to the same login system -- pam. (pluggable authentication...
1,148
Posted By PikK45
I believe there are few changes needed. This will...
I believe there are few changes needed. This will definitely get into a infinite loop due to highlighted lines :)

May be you have to set a variable for the next second ;)
Showing results 1 to 25 of 28

 

Featured Tech Videos

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