Search Results

Search: Posts Made By: mirni
3,482
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,...
4,518
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...
4,449
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,371
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...
1,660
Posted By mirni
Like this? awk '/^[^>]/ && length($0)<10{print...
Like this?
awk '/^[^>]/ && length($0)<10{print hdr"\n"$0}{hdr=$0}' input
4,073
Posted By mirni
What did you try to achieve with this line? ...
What did you try to achieve with this line?
user=$user
I'd bet $user is not set. You probably want to do any of these equivalent ways to get the current user:
chown -R $USER extracted
chown -R...
5,285
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,825
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,825
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,825
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
4,315
Posted By mirni
Try: awk '!a[$1]++||($2-old[$1] >...
Try:
awk '!a[$1]++||($2-old[$1] > 30){print}{old[$1]=$2}'Based on the logic you described, you are missing line
AN134 338 426496 1906 1 UNE Cefaclor in your sample output,...
14,139
Posted By mirni
It's because you missed scrutinizer's point. ...
It's because you missed scrutinizer's point.

[0-9]* matches zero or more digits, so it matches the beginning of the line (containing zero digits)
[0-9][0-9]* matches one or more digits

echo...
14,139
Posted By mirni
Try sed 's/^[0-9]*/& /' file
Try
sed 's/^[0-9]*/& /' file
1,638
Posted By mirni
Try: awk -v ft=$ftmp '{i=i++%3+1; ...
Try:
awk -v ft=$ftmp '{i=i++%3+1; i2=(i==1)?i2+1:i2; print > ft"."i2"."i}' RS="\n>\n" p.dat
1,875
Posted By mirni
With perl you can specify a backup extension...
With perl you can specify a backup extension after the -i switch:
perl -i.bak 's/:\S*//g' file #will save the original as file.bakGNU sed can also edit in-place, here is sed solution:
sed -i 's/:[^...
12,702
Posted By mirni
The outer brackets mean "character class", same...
The outer brackets mean "character class", same as if you do [0-9] or [a-z], the inner brackets are the characters to be matched (any of the two). Ampersand recalls the pattern that was matched (in...
1,875
Posted By mirni
Awk is a filter, it doesn't modify the input. You...
Awk is a filter, it doesn't modify the input. You should redirect into a temporary file, then overwrite the original.
How about:

cp $input ${input}.copy
awk -F: '{print $1}' RS="[ \t]+" ORS=" "...
12,702
Posted By mirni
Like this? sed 's/[][]/\\&/g' And please...
Like this?
sed 's/[][]/\\&/g'

And please use code tags when posting code or sample input/output.
3,378
Posted By mirni
Use semicolon to execute commands consecutively....
Use semicolon to execute commands consecutively. You are incorrectly using pipe instead.
The easiest way is to do:

if grep -q string file.txt ; then
echo "string found"
else
echo "not...
18,283
Posted By mirni
encrypt: echo ${username}:${password} |...
encrypt:

echo ${username}:${password} | openssl des3 -salt -pass pass:$password -out credentials.txt.enc

Decrypt:

openssl -d des3 -salt -pass pass:${password} -in credentials.txt.enc -out...
18,283
Posted By mirni
I like to use openssl. Something like this should...
I like to use openssl. Something like this should do the trick:

#!/bin/bash
decrypt=credentials.txt
encrypt=${decrypt}.encrypted

if [[ $# -eq 0 ]] ; then
echo "Gimme username"
...
3,315
Posted By mirni
Try join -t' ' -j 1 file1 <(sed 's/,/ ...
Try
join -t' ' -j 1 file1 <(sed 's/,/ /g' file2)
Input the tab as ctrl+v ctrl+i.

Your awk line can also be made to work:
awk -F' ' 'NR==FNR{a[$1];next}$1 in a' file1 <(sed...
4,827
Posted By mirni
Please use code tags when posting code. ...
Please use code tags when posting code.

Apart from PROJ_NAME unintialized you are missing two dollar signs:

filelist=project_name/files/
source_dir=${PROJ_NAME}/Temp/...
2,107
Posted By mirni
Don't get too distracted with the here-document...
Don't get too distracted with the here-document construct. It is the same as if you saved it into a file, and then fed the file into a while loop via < operator:
while [] ; do
...
done < file...
2,590
Posted By mirni
Naive way: awk '{a=""; for(i=1;i<=NF;i++)...
Naive way:
awk '{a=""; for(i=1;i<=NF;i++) a=a?(a "=" $i):$i ; print a}' RS= names.txt

or more elegant:
awk '$1=$1' OFS="=" RS= names.txt
Showing results 1 to 25 of 169

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