for i in `ls cdr.30_JUL_2012*`; do perl -e 'while(<>) {@fields=split(/\|/,$_);$fields[5]="hello";for($i=0;$i <= $#fields; $i++){ print "$fields[$i]|";}}' $i > hello.$i; done &
Tuesday, 31 July 2012
Monday, 30 July 2012
Read line from file1 and search string in other files
IFS='/'; while read line ; do { arr=($line); exp="${arr[1]}${arr[2]}"; tmp=`echo $exp | sed -e 's/"//'`; if [ -z $tmp ]; then continue; fi; len=`expr length $tmp`; if [ $len -gt 30 ]; then grep "${arr[1]}/${arr[2]}" mig_proxy.cdr.26_JUL_2012_mig* | grep -v ${arr[0]}; fi } done < cdr.26_JUL_2012* > report.26_JUL_2012 2>&1
--brief: read line from has delimited by "/" and take third splitted str and search string in other files
--brief: read line from has delimited by "/" and take third splitted str and search string in other files
Friday, 27 July 2012
Multiply two intergers using bitwise operator
#include<stdio.h>
void main()
{
int a,b,result;
printf("Enter the numbers to be multiplied :\n");
scanf("%d%d",&a,&b);
result=0;
while(b != 0)
{
if (b&0x01)
{
result=result+a;
}
a<<=1;
b>>=1;
}
printf("Result:%d",result);
}
void main()
{
int a,b,result;
printf("Enter the numbers to be multiplied :\n");
scanf("%d%d",&a,&b);
result=0;
while(b != 0)
{
if (b&0x01)
{
result=result+a;
}
a<<=1;
b>>=1;
}
printf("Result:%d",result);
}
Sunday, 26 February 2012
List files not accessed for a week
find ./ -atime +30 -type f -exec rm {} \;
@brief: find the files in current directory whose are not accessed for 30 days and remove the same.
@brief: find the files in current directory whose are not accessed for 30 days and remove the same.
Monday, 23 January 2012
get files count and list from all sub directories
#!/bin/bash
DIRS=$(find "$1" -type d)
for d in $DIRS
do
[ "$d" != "." -a "$d" != ".." ] && echo -e "$d $(ls $d | wc -l)\n$(ls $d)" || :
done
DIRS=$(find "$1" -type d)
for d in $DIRS
do
[ "$d" != "." -a "$d" != ".." ] && echo -e "$d $(ls $d | wc -l)\n$(ls $d)" || :
done
Saturday, 7 January 2012
Untar all files in a single directory
---- List all tgz files and untar them and put into specified single directory
for file in `ls -1 mig_proxy.cdr.06_JAN_2012.*`;do tar zxvf $file -C temp/ ; done
Here temp is where the extracted files will be placed ..
for file in `ls -1 mig_proxy.cdr.06_JAN_2012.*`;do tar zxvf $file -C temp/ ; done
Here temp is where the extracted files will be placed ..
Wednesday, 16 November 2011
Search and Replace in awk
ls -R | gawk '{if($1 ~ /.*:$/){split($1,a,"/");if(a[length(a)] ~ /[a-z]/){if(length($1) > 10){print $1;}}}}' | awk '{ sub(/[:]$/, ""); print }' | xargs rm -rf
Subscribe to:
Posts (Atom)