---
title: "awk引用shell中带meta字符的字符串 "
author: "Dustin"
date: "2009-03-25T20:45:14Z"
tags: []
slug: "awk-shell-meta"
draft: false
lastmod: "2009-04-07T15:07:34Z"
id: 355065
url: "https://dustin.iteye.com/blog/355065"
---

```
link='http://localhost:8080 Blog='
more id_list.txt |awk "{print \"$link\"\$1}"
```

 

   上面这段代码完成的功能是将id\_list.txt中的每一行的内容拼接到link变量后，并将拼接后的内容输出到控制台。譬如，如果id\_list.txt中的内容为：

```
123
456
789
```

 

   那么，控制台将输出下面的内容：

```
http://localhost:8080 Blog=123
http://localhost:8080 Blog=456
http://localhost:8080 Blog=789
```

  

    关于shell中单双引号的区别以及shell变量如何跟awk交互，参看[这里](http://bbs.chinaunix.net/viewthread.php?tid=218853&amp%3Bamp%3Bextra=&amp%3Bamp%3Bpage=4#pid1511745)。