---
title: "awk system函数 调用sql语句"
author: "wtgame"
date: "2010-12-30T05:10:17Z"
tags: []
categories: ["非技术"]
slug: "awk-system-sql"
draft: false
lastmod: "2010-12-30T05:15:09Z"
id: 855394
url: "https://wtgame.iteye.com/blog/855394"
---

awk 'BEGIN{system("mysql -u root -p1q2w3e test -Bse \\"select * from test where type='\\''""A""'\\''\\"")}'

```

```

 

 

awk 的system调用一个sql语句,sql语句中的where条件来自一个file的$1

 

\[root@jerome-1 awk]# cat file  | awk '{print $1}'  
A

 

echo | awk '{system("mysql -u root -p1q2w3e test -Bse \\"select * from test where type='\\''"$1"'\\''\\"")}' file

 

```

```