bash - Escape awk $ in shell function of bashrc -


i have command gets next id of table pool of sql files, trying put command alias in ~/.bashrc using shell function, did not figure out how escape $ gets awk , not replaced bash, here's code in .bashrc:

function nextval () {     grep 'insert \""$1"\"' *.sql | \     awk '{print $6}' | \     cut -c 2- | \     awk -f "," '{print $1}' | \     sort -n | \     tail -n 1 | \     awk '{print $0+1}' }  alias nextval=nextval 

usage: # nextval tablename

escaping \$ error: awk: backslash not last character on line. $ not inside double quotes, why bash replacing ?

perhaps part need change this

'insert \""$1"\"' 

to

"insert \"$1\"" 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -