generate a awk script that will clip your bed records:
mysql --user=genome -N --host=genome-mysql.cse.ucsc.edu -A -D hg19 -e 'select chrom,size from chromInfo ' |\
awk '{printf("($1==\"%s\") {L=%d;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf(\"%s\\t%%d\\t%%d\\n\",B,E);next;}\n",$1,$2,$1);}' > script.awk
$ head script.awk
($1=="chr1") {L=249250621;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr1\t%d\t%d\n",B,E);next;}
($1=="chr2") {L=243199373;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr2\t%d\t%d\n",B,E);next;}
($1=="chr3") {L=198022430;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr3\t%d\t%d\n",B,E);next;}
($1=="chr4") {L=191154276;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr4\t%d\t%d\n",B,E);next;}
($1=="chr5") {L=180915260;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr5\t%d\t%d\n",B,E);next;}
($1=="chr6") {L=171115067;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr6\t%d\t%d\n",B,E);next;}
($1=="chr7") {L=159138663;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr7\t%d\t%d\n",B,E);next;}
($1=="chrX") {L=155270560;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chrX\t%d\t%d\n",B,E);next;}
($1=="chr8") {L=146364022;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr8\t%d\t%d\n",B,E);next;}
($1=="chr9") {L=141213431;B=int($2);E=int($3);B=(B>=L?L:B);E=(E>=L?L:E);printf("chr9\t%d\t%d\n",B,E);next;}
then use this awk script :
awk -f script.awk input.bed
Fixed it with bedClip, thank you for your help!