Search Results

Search: Posts Made By: Roozo
6,146
Posted By durden_tyler
While you can always fix the date format using a...
While you can always fix the date format using a scripting language after you get it out of the database, you may want to explore the possibility of getting it in the correct format from the database...
6,146
Posted By Aia
A Perl alternative: perl -pe...
A Perl alternative:

perl -pe 's/(\d{4})-(\d{2})-(\d{2})/$3\/$2\/$1/' roozo.file

Output:
SAP|23/03/2017
REEF-U|24/03/2017
FEB|12/06/2016
BEN-JEF|23/09/2017
TUJJI|30/03/2017
6,146
Posted By RudiC
How about awk 'BEGIN {FS = OFS = "|"} {split...
How about
awk 'BEGIN {FS = OFS = "|"} {split ($2, T, "-"); print $1, T[3] "/" T[2] "/" T[1]}' file
SAP|23/03/2017
REEF-U|24/03/2017
FEB|12/06/2016
BEN-JEF|23/09/2017
TUJJI|30/03/2017
1,735
Posted By Akshay Hegde
This might help you to start awk 'function...
This might help you to start
awk 'function error(v){
print "invalid "v ; exit
}

BEGIN{
month="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
split(month,MON,/ /)

...
1,735
Posted By Don Cragun
When you say that the following is working from...
When you say that the following is working from the command line:
echo "2014-09-10" | awk
-F '/'
'{print ( $1 >0 && length($1) == 4 && $2 <= 12 && $3 <= 31 ) ? "good" : "bad" }'
did you mean...
4,214
Posted By bigearsbilly
Here is my own little concoction I use for such...
Here is my own little concoction I use for such things.
Produces output like:

=====================================
host total FIN_WAIT2 ESTABLISHED
192.168.1.115 | ...
4,214
Posted By balajesuri
Looks like you managed to print just the state of...
Looks like you managed to print just the state of each server.
Now, try to push each state as the key in an associative array and keep incrementing the value each time you find the same state in the...
1,410
Posted By Don Cragun
ed -s file <<-EOF g/Pattern to...
ed -s file <<-EOF
g/Pattern to find/s//replacement string/g
w
q
EOF
1,410
Posted By Don Cragun
There is always the straightforward ed or ex that...
There is always the straightforward ed or ex that you can use to edit a file:
ed -s file <<-EOF
g/Pattern to delete/d
w
q
EOF

Leave off the -s option if you want to...
1,410
Posted By disedorgue
Hi, If you have perl: perl -i -n -e...
Hi,
If you have perl:
perl -i -n -e 'if(!/Pattern to delete/) {print}' file
Regards.
4,617
Posted By Akshay Hegde
Yes., this will avoid memory problem.
Yes., this will avoid memory problem.
4,617
Posted By Akshay Hegde
OR Try if second file size is too big...
OR

Try

if second file size is too big then you may have to face memory problem

$ awk 'FNR==NR{A[$1+0]; next}{if($3+0 in A){$5=replace;print}else{last[++i]=$0}}END{for(j=1;j<=i;j++)print...
1,210
Posted By Akshay Hegde
Try : $ awk 'BEGIN{ print "Enter input ";...
Try :

$ awk 'BEGIN{ print "Enter input "; getline input < "-"; print input >"output_file" }'
Enter input
Roozo

$ cat output_file
Roozo
4,617
Posted By Akshay Hegde
By adding0 awk treats array index$1 as numeric...
By adding0 awk treats array index$1 as numeric value, if you do not add 0 then string

Example :

$ awk 'FNR==NR{A[$1]; next}END{for(i in A)print i }' input
55
066

$ awk 'FNR==NR{A[$1+0];...
4,617
Posted By Scrutinizer
Hi, try this fix: awk 'FNR==NR{A[$1+0]; next}...
Hi, try this fix:
awk 'FNR==NR{A[$1+0]; next} $3+0 in A{$5=replace}1' replace=77 FS=, OFS=, input.txt file
4,617
Posted By Scrutinizer
It is more efficient to use $3 in A instead of...
It is more efficient to use $3 in A instead of A[$3]:
awk 'FNR==NR{A[$1]; next} $3 in A{$5=replace}1' replace=77 FS=, OFS=, input.txt file

Then there is no need for A[$1]++ which saves an...
4,617
Posted By Akshay Hegde
You are appending in every iteration below one...
You are appending in every iteration below one does your job


Try :

$ awk -F, 'FNR==NR{A[$1]++;next}A[$3]{$5=replace}1' replace=77 OFS=\, input.txt file >output.txt

$ cat output.txt...
2,300
Posted By Akshay Hegde
for input posted in #10 $ cat input1.txt ...
for input posted in #10

$ cat input1.txt
aster;PAGE;1233;4;1222

$ cat input2.txt
1111 A
1234 B
9999 B
2355 C

$ cat input3.txt
1111 2
1234 1
9999 3
2355 4

$ cat config.txt
A...
2,300
Posted By neutronscott
wow this is just getting more and more complex!...
wow this is just getting more and more complex! This was fun. Would be more understandable if I knew what I was working with and could name the variables something..


mute@thedoctor:~/temp/roozo$...
2,300
Posted By Akshay Hegde
For input in post #6 and order is important then...
For input in post #6 and order is important then you may try

$ cat config.txt
A DART
B MART
B KART
B KAR2
C HOME

$ cat input2.txt
1111 A
1234 B
2355 C

$ cat input1.txt ...
2,300
Posted By neutronscott
mute@thedoctor:~/temp/roozo$ ./script ...
mute@thedoctor:~/temp/roozo$ ./script
aster;PAGE;1234;4;KART
aster;PAGE;2355;4;HOME
aster;PAGE;1234;4;KAR2
aster;PAGE;1234;4;MART
aster;PAGE;1111;4;DART



#!/bin/sh
awk '
...
2,300
Posted By Yoda
Are you trying to join three files? If yes,...
Are you trying to join three files?

If yes, something like this might work for the input that you posted:
awk -F'[; ]' '
NR == FNR {
i = $2
next
...
1,711
Posted By hergp
If your ksh is ksh93 you can also use the builtin...
If your ksh is ksh93 you can also use the builtin date formatting capability:

d=$(printf "%(%Y%m%d%H%M%S)T" "30 day ago")


To check for ksh93 just use

print $KSH_VERSION


If the output...
876
Posted By Yoda
awk 'NR==FNR{A[$1];next}!($1 in A){print $1}'...
awk 'NR==FNR{A[$1];next}!($1 in A){print $1}' file2 file1
995
Posted By Jotne
awk 'NR==1 {print s1$0e} NR!=1 {print s2$0e}'...
awk 'NR==1 {print s1$0e} NR!=1 {print s2$0e}' s1="root a.directory from '" s2="bin a.directory from '" e="'" input.txt
root a.directory from 'tan23'
bin a.directory from 'cos87'
bin a.directory...
Showing results 1 to 25 of 29

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