Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: mirni
2,447
Posted By mirni
No, you don't have it correctly. There are a...
No, you don't have it correctly. There are a couple problems with your line:
1. convert takes 2 filenames:
convert <inputfile> <outputfile>
If you want to perform the operation on the same file,...
2,751
Posted By mirni
Tricky part is that commas may be present within...
Tricky part is that commas may be present within the field (that's why the quotes)
Yoda's solution will not work for files that have more than 6 columns, or files that have commas in the last two...
3,473
Posted By mirni
You missed the type: find...
You missed the type:

find /local/home/app/cases -iname '*\.sh' -type f -exec chmod -c 744 {} \;
Escaping the period is not really necessary, and if there is a lot of files, using xargs is more...
Forum: Programming 02-12-2014
1,495
Posted By mirni
Fantastic! Thank you guys for pointing me in...
Fantastic!
Thank you guys for pointing me in the right direction!
Forum: Programming 02-12-2014
1,495
Posted By mirni
Signal out from fork()'d shell script back to the C++ application
Hi,
I am writing a C++ application; in which at one point I fork() a new process, which executes a shell script (via execv() call).
Now the shell script can take a while to finish (tarring, burning...
Forum: Programming 01-02-2014
1,708
Posted By mirni
Mount from C code with --no-mtab?
Hi all,
I am writing a mount/umount procedure for CD rom and getting into the problem that /etc/mtab is not in sync with /proc/mounts.
Then I am ending up with a bunch of dangling /etc/mtab entries...
16,202
Posted By mirni
From man ssh :
From man ssh :
3,406
Posted By mirni
Better yet, change IFS only locally, for this...
Better yet, change IFS only locally, for this while loop. And you can avoid the cutting if you just throw in another dummy variable:

while IFS='|' read first second rest ; do
echo $second ...
2,407
Posted By mirni
1,$ line range; apply the following command...
1,$ line range; apply the following command on all lines ('$' in this context means last line). This part can be omitted since the full range is default.
s/foo/bar/g substitute (s) 'foo'...
969
Posted By mirni
Or awk '{for(i=1;i<=NF;i++) $i=$i" "$i+1"...
Or
awk '{for(i=1;i<=NF;i++) $i=$i" "$i+1" "$i-1}1' numbers.txt
2,857
Posted By mirni
I agree that awk solution is more readable, but...
I agree that awk solution is more readable, but just for the heck of it, here is sed command that should do the trick:
sed 's/.*\("[^"]*"\).*/\1/'
1,115
Posted By mirni
Like this? awk '/^[^>]/ && length($0)<10{print...
Like this?
awk '/^[^>]/ && length($0)<10{print hdr"\n"$0}{hdr=$0}' input
1,061
Posted By mirni
May I ask what do you expect from testing against...
May I ask what do you expect from testing against the same condition twice?


Try:
awk -F- '/FAILURE/{if(!seen[$5,$6]){cnt[$5]++; seen[$5,$6]++; } if(cnt[$5]>10) print $5,$6}' logfileNote that...
873
Posted By mirni
Try egrep -m1 '/user/data/[0-9]{7}/'
Try
egrep -m1 '/user/data/[0-9]{7}/'
1,075
Posted By mirni
find /mahe -mmin -30 -ls
find /mahe -mmin -30 -ls
1,075
Posted By mirni
less than 30 minutes ago: -mmin -30 It's all in...
less than 30 minutes ago: -mmin -30
It's all in the manual: man find
1,075
Posted By mirni
You can use -mtime of find(1). -mtime -1 would...
You can use -mtime of find(1). -mtime -1 would list files newer than 24 hours. Alternatively, you can make a timestamp every midnight (from cron), and check with -nt, if your shell's test...
8,570
Posted By mirni
Perl and sed are not the same thing. Although I...
Perl and sed are not the same thing. Although I am quite rusty in Perl, this should do the trick:
perl -pe s'/([][])/\\$1/g'
3,071
Posted By mirni
Try this: awk ' {a[$1,$2]=$3; b[$1];} END{ ...
Try this:
awk '
{a[$1,$2]=$3; b[$1];}
END{
for(i in b) #print header
printf("\t%s",i);
printf("\n");
for(i in b) { #each row
printf("%s\t",i);
for(j in b) #each...
1,172
Posted By mirni
awk -F"[=,]" '{prev=$4; print; getline; print...
awk -F"[=,]" '{prev=$4; print; getline; print $0","($4-prev)/($4<0?-$4:$4)*100"%"}' input

The highlighted part basically does an absolute value of $4.
Note that you'll get into problems if the...
1,172
Posted By mirni
You can split on either = or , and hard-code 4th...
You can split on either = or , and hard-code 4th column:

awk -F"[=,]" '{prev=$4; print; getline; print $0","($4-prev)/$4*100"%"}' input
1,701
Posted By mirni
Or: cat inputfile | tr '\n' ' ' | sed 's/ CAR...
Or:
cat inputfile | tr '\n' ' ' | sed 's/ CAR /\nCAR /g; s/ $/\n/'
1,172
Posted By mirni
Try this: awk -F= '{prev=$NF; print; getline;...
Try this:
awk -F= '{prev=$NF; print; getline; print $0","($NF-prev)/$NF*100"%"}' input
2,081
Posted By mirni
Yes, it would, absolutely.
Yes, it would, absolutely.
1,495
Posted By mirni
What system are you on? What awk are you using? ...
What system are you on? What awk are you using?
If on Solaris, use nawk instead.
Showing results 1 to 25 of 500

 

Featured Tech Videos

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