Linux - 将文本文件的每一行与传递给函数的参数连接起来

标签 linux bash concatenation

我有一个 .sh 函数,它接受参数 $1 的路径。 我有一个带有文件名的文本文件。 我需要将 $1 的值连接到我的文本文件的每一行

txt file:
   file1.jpg
   file2.jpg

argument:
   $1 = path/
   $2 = to/dir/

目标

txt file:
    path/to/dir/file1.jpg
    path/to/dir/file2.jpg

最佳答案

仍然假设文件中的行包含部分路径数据,并且只是扩展我评论中的想法,您会得到:

sed -e "s!^!$1/$2/!" file

关于Linux - 将文本文件的每一行与传递给函数的参数连接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26521075/

相关文章:

linux - 有没有办法重命名 Cargo 项目?

linux - Eclipse 的一个窗口中的 Bash shell

bash - 如何使用 bash 替换 csv 文件中特定位置的字符串

mysql - grep 文件中的特定参数

python - 将多索引数据帧与数据帧连接起来

c - pthread_join :warning: cast from pointer to integer of different size?

linux - 如何构建使用自定义库的外部 linux 模块

Python Pandas Concat 具有不同列和相同行的数据框列表

matlab - 如何获得矩阵的对角线并将它们连接起来?

linux - Bash 脚本 - 如何设置创建新文件的组?