Search Results

Search: Posts Made By: gani_85
Forum: UNIX and Linux Applications 02-15-2013
12,441
Posted By novaothers
# Establish DB connection ret=`db2 connect to...
# Establish DB connection
ret=`db2 connect to $1`
ret=`echo "$ret"`

if [[ -z $ret ]] then
echo "Error connecting to $1 database."
exit 1
else
echo "Successfully...
1,742
Posted By Chubler_XL
Example to replace fields 2, 3 and 19 with '*' to...
Example to replace fields 2, 3 and 19 with '*' to field length (subsitute with the field#s you want to replace).

awk 'BEGIN{split("2,3,19", F, ",")} {for(fld in F) gsub(/./, "*", $fld)}1' filename
1,742
Posted By Yoda
awk '{ for(i=1;i<=NF;i++) if(length($i)==20)...
awk '{ for(i=1;i<=NF;i++) if(length($i)==20) gsub(/./,"*",$i); }1' filename
2,774
Posted By balajesuri
If you have GNU date, try this: while IFS='|'...
If you have GNU date, try this:
while IFS='|' read a b c; do echo "$a|`date -d$b +%Y%m%d`|$c"; done < inputfile
2,774
Posted By balajesuri
It's not working because you put that thing in an...
It's not working because you put that thing in an awk statement. Just put it as is on command line (ofcourse by substituting the filename to whatever contains your input)

Also, check if you have...
2,774
Posted By balajesuri
#! /usr/bin/perl -w use strict; open I, "<...
#! /usr/bin/perl -w
use strict;

open I, "< inputfile";
for (<I>) {
chomp;
my @x = split /\|/;
$x[1] = parse_date ($x[1]);
print join ('|', @x), "\n";
}
close I;

sub...
2,774
Posted By clx
I know its dirty but worth to post. $...
I know its dirty but worth to post.

$ mth=JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC
$ awk -F\| -v mlist=$mth '{split($2,A,"-") ;printf("%s|20%d%02d%d|%s\n", $1,A[3],(index(mlist,A[2])+2)/3,A[1],$3)}'...
2,768
Posted By kalpeer
Thanks Guru, Could you please explain this...
Thanks Guru,

Could you please explain this pattern sed 's/\(.*_\)\(....\)\(..\)\(..\)/\1\4\3\2/'` , It will be very helpful.
2,768
Posted By guruprasadpr
$ x="abc_test_20120213.dat" $ y=`echo $x |...
$ x="abc_test_20120213.dat"

$ y=`echo $x | sed 's/\(.*_\)\(....\)\(..\)\(..\)/\1\4\3\2/'`

$ echo $y
abc_test_13022012.dat


Guru.
2,768
Posted By balajesuri
x='abc_test_20120213.dat' y=${x%_*} z=$(date...
x='abc_test_20120213.dat'
y=${x%_*}
z=$(date -d `echo ${x%.dat} | cut -d_ -f3` +%d%m%Y)
echo "${y}_$z.dat"
1,711
Posted By bartus11
Try: awk -F\" -vOFS="\"" '{for (i=2;i<=NF;i+=2)...
Try: awk -F\" -vOFS="\"" '{for (i=2;i<=NF;i+=2) sub(",","",$i)}1' file
1,711
Posted By Scrutinizer
Alternatively: awk 'NR%2-1{gsub(/,/,x)}1' RS=\"...
Alternatively:
awk 'NR%2-1{gsub(/,/,x)}1' RS=\" ORS=\" infile
Showing results 1 to 12 of 12

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