bash - Command line commands in a shell script
问题描述
I have a command that I use in the command line to replace certain lower case characters with upper case, which works fine:
cat file | sed -e 's/^ g/G /;s/^ h/H /;s/^ n/N /;s/^ b/B /' > newfile
Is there a way I can write this into a shell script and call
bash uppercase.sh file
instead of copy and pasting into the command line every time?
Currently when I copy and paste the command into a shell script like:
#!/bin/bash
sed -e 's/^ g/G /;s/^ h/H /;s/^ n/N /;s/^ b/B /'
The terminal becomes unresponsive
解决方案
尝试将 '$1' 附加到脚本中的 sed 命令,如下所示:
#!/bin/bash
sed -e 's/^ g/G /;s/^ h/H /;s/^ n/N /;s/^ b/B /' $1
然后,像这样运行它:
bash uppercase.sh file
推荐阅读
- c# - JavaScriptSerializer 序列化星期属性
- zipkin - Brave 的有效 traceId 是什么?
- python - 在 R Studio 中加载 GloVe 文本文档
- discord.py - How I can load a font file with PIL.ImageFont.truetype in replit
- java - PropertyReferenceException:Spring Data JPA 错误找不到类型的属性
- python - docker+sanic: curl: (52) 来自服务器的空回复
- github - Github 代码检索返回 sha hash 而不是实际代码
- tinymce - 如何配置 TinyMCE 以允许
里面一个
标签 - uinavigationcontroller - 有没有办法减少初始视图控制器上的 prefersLargeTitles 上面的空间?
- php - 如何像 Magento 前视图一样从 Venia 店面更新过滤器?