Search Results

Search: Posts Made By: Devendra Hupri
973
Posted By ramkumar15
thanks a lot for all your help its works now.
thanks a lot for all your help its works now.
1,454
Posted By RavinderSingh13
Hello Devendra, Your Input data as per first...
Hello Devendra,

Your Input data as per first post is as follows.(in which there is only 1 line not 2 fields at each line, I made a slight change in that to show you that code is not properly...
1,454
Posted By RudiC
Try alsoawk '!(NR%2) {if ($1 > MAX) MAX=$1} END...
Try alsoawk '!(NR%2) {if ($1 > MAX) MAX=$1} END {print MAX}' RS=" " file
5
1,454
Posted By RavinderSingh13
Hello Devendra, Could you please try...
Hello Devendra,

Could you please try following and let me know if this helps you.

awk '{for(i=1;i<=NF;i++){if(i%2==0){A[j]=A[j]>$i?A[j]:$i} if(i%2!=0){j=$i}}} END{for(u in A){print u OFS...
1,454
Posted By anbu23
Can you add Code tags? Do you want max of X...
Can you add Code tags?

Do you want max of X for each timestamp or for entire input?
1,775
Posted By Don Cragun
According to the standards, options must appear...
According to the standards, options must appear on a command line before operands. On most systems getopts enforces that requirement as you have found. There are ways to get around that, but since...
5,369
Posted By RavinderSingh13
Hello Devendra, I have figured it out(sorry...
Hello Devendra,

I have figured it out(sorry for confusion), we need to give complete path while deleting the directories while passing it from awk to sh as follows.

####To delete the...
5,369
Posted By RavinderSingh13
Hello Devendra, Code given in POST#5 is...
Hello Devendra,

Code given in POST#5 is working fine for me, not sure(surprised) why it is not working for you.
Let me know if you got any error after executing it. The only difference between...
5,369
Posted By MadeInGermany
Thanks for the fix, Don. I had typed that in a...
Thanks for the fix, Don. I had typed that in a hurry.
I guess it was the second suggestion that worked.
Another suggestion, do the cd in a sub shell so it does not harm the main shell:
(cd $TGTDIR...
5,369
Posted By Don Cragun
OK. So the ls -t $TGTDIR gives you filenames in...
OK. So the ls -t $TGTDIR gives you filenames in $TGTDIR, not absolute pathnames. So you either removed files (of any type; not necessarily directories) in the directory where you ran this script...
5,369
Posted By Don Cragun
One last time: In what way did the command: rm...
One last time:
In what way did the command: rm -rf `ls -t $TGTDIR | awk 'NR>5'` "not work"?
5,369
Posted By RavinderSingh13
Hello Devendra Hupri, Seems to me a...
Hello Devendra Hupri,

Seems to me a permission issue, could you please confirm/make sure you have proper permissions to the directories,
let us know the error messages in case you have queries....
5,369
Posted By Don Cragun
I repeat: What shell are you using? In...
I repeat:
What shell are you using?

In what way did the command:rm -rf `ls -t $TGTDIR | awk 'NR>5'` "not work"? If it produces diagnostic messages, show them to us (in CODE tags).
5,369
Posted By Don Cragun
What operating system and shell are you using? ...
What operating system and shell are you using?

In what way did it not work?

Are there any files other than directories in the directory named by $TGTDIR? Could non-directory files in $TGTDIR...
5,369
Posted By RavinderSingh13
Hello Senhia, I didn't test your code but...
Hello Senhia,

I didn't test your code but rmdir will work only if directories are empty(User didn't mention here about the same either directories are empty or not).

Hello Devendra Hupri,
...
5,369
Posted By MadeInGermany
Variants of your quick-and-dirty command rm -rf...
Variants of your quick-and-dirty command
rm -rf `cd $TGTDIR && ls -t | awk 'NR>5'`
rm -rf `ls -dt $TGTDIR/* | awk 'NR>5'`
5,369
Posted By senhia83
Not tested, but maybe some form of the following...
Not tested, but maybe some form of the following might work ? Please try on a dummy set first..
Waiting on a second opinion

find /TGTDIR/ -maxdepth 1 -type -d -name '*' -print0 | xargs -r0 ls -t...
5,369
Posted By RavinderSingh13
Hello Devendra Hupri, Welcome to forum,...
Hello Devendra Hupri,

Welcome to forum, following may help you in same.
1st command:

TGTDIR=/tmp ##For ust an example
ls -ltr $TGTDIR | awk '/^d/ {A++;X[++j]=$NF}...
Showing results 1 to 18 of 18

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