首页 > 系统相关 >Shell - Pass output as argument to next command

Shell - Pass output as argument to next command

时间:2023-12-28 13:23:44浏览次数:23  
标签:rw zzh db argument next down Shell migration sql

 

In bash we can pass the output of one command to the next one as an argument. We will cover multiple examples.

xargs is very useful for passing information between commands when chaining is used in Bash:

echo -e "Python\nJava" | xargs -I{} echo 'test me in' {}

result:

test me in Python
test me in Java

Another example of passing output as argument with cURL:

cat urls.txt | xargs -I % curl http://example.com/%.json

 

zzh@ZZHPC:/zdata/Github/zimplebank$ ls -1 db/migration/*.down.sql | xargs -I{} ls -l {}
-rw-rw-r-- 1 zzh zzh 160 Dec 27 19:36 db/migration/000000_init_schema.down.sql
-rw-rw-r-- 1 zzh zzh 40 Dec 27 19:36 db/migration/000001_add_sessions.down.sql
-rw-rw-r-- 1 zzh zzh 105 Dec 27 19:37 db/migration/000002_add_verification_emails.down.sql
zzh@ZZHPC:/zdata/Github/zimplebank$ ls -1 db/migration/*.down.sql | xargs -I % ls -l %
-rw-rw-r-- 1 zzh zzh 160 Dec 27 19:36 db/migration/000000_init_schema.down.sql
-rw-rw-r-- 1 zzh zzh 40 Dec 27 19:36 db/migration/000001_add_sessions.down.sql
-rw-rw-r-- 1 zzh zzh 105 Dec 27 19:37 db/migration/000002_add_verification_emails.down.sql

 

标签:rw,zzh,db,argument,next,down,Shell,migration,sql
From: https://www.cnblogs.com/zhangzhihui/p/17932481.html

相关文章

  • Linux shell编程学习笔记36:read命令
     *更新日志 *2023-12-181.根据[美]威廉·肖特斯(Willian shotts)所著《Linux命令行大全(第2版)》            更新了-e、-i、-r选项的说明           2.更新了2.8的实例,增加了gif动图           3.补充......
  • shell脚本中的“请按任意键继续”
    原贴:https://www.cnblogs.com/bazingafraser/p/9116393.html1234567891011121314151617181920#!/bin/bash  get_char(){SAVEDSTTY=`stty-g`stty-echosttycbreakddif=/dev/ttybs=1count=12>/dev/nullstty-rawsttyecho......
  • Shell脚本中获取机器的日期和时间
    要在Shell脚本中获取机器的日期和时间,可以使用内置的date命令。以下是如何在Shell脚本中使用date命令来获取机器的日期和时间的示例: echo"`date+"%Y%m%d%H:%M:%S"`"在这个示例中,我们使用了date命令和格式化字符串来获取当前日期和时间。%Y代表年份,%m代表月份,%d代表日期,%H代表......
  • 相关业务SHELL脚本
    SHELL脚本:基于shell实现不同服务器root密码的统一遇到的问题:发现旧密码如果含有一些特殊符号,如"}","{"等,使用expect的话就会出现问题。#!/bin/bash#多个服务器修改密码的脚本file=./10-bt.txtnew_passwd='12\}2231321'whilereadippasswddoecho$passwdexpect......
  • Nextjs SyntaxError: Cannot use import statement outside a module错误
    NextJs报 SyntaxError:Cannotuseimportstatementoutsideamodule第三方依赖不能导入问题 解决方案:1,Next.JS13.1+,可以使用next.config.js中的属性transpilePackagesconstnextConfig={transpilePackages:['the-npm-package'],//第三方的依赖};module.expo......
  • Windows Server 2019-Powershell之客户端加域
    将本地计算机添加到域或工作组,可通过Add-Computer命令操作,具体信息如下:语法:Add-Computer[-DomainName][-ComputerName<String[]>][-Confirm]-Credential[-Force][-LocalCredential][-NewName][-OUPath][-Options{AccountCreate|Win9XUpgrade|UnsecuredJoi......
  • openjdk源码-java是如何执行shell命令的
    一般我们在java中调用shell脚本的方式如下publicintexecuteLinuxCmd(Stringcmd){LOGGER.info("cmd:{}",cmd);Runtimerun=Runtime.getRuntime();try{Processprocess=run.exec(cmd);InputStreamin=proce......
  • Centos7使用Docker部署Nextcloud
    基础环境系统centos7.9内存2G以上磁盘30G以上安装部署1、安装基础工具[root@localhost~]#yum-yinstallvimnet-toolsnmaptreelrzszlsof2、添加阿里docker源[root@localhost~]#wget-P/etc/yum.repos.d/https://mirrors.aliyun.com/docker-ce/linux/centos/docker-......
  • 无涯教程-Java9 - JShell(REPL)
    REPL代表"Read-Eval-PrintLoop"。使用JShell,java具有REPL函数。使用REPL,无涯教程可以对基于Java的逻辑进行编码和测试,而无需使用javac进行编译,并且可以直接查看计算输出。运行JShell打开命令提示符,然后键入jshell。$jshell|WelcometoJShell--Version9-ea|Forani......
  • 扫描全能王启动鸿蒙原生应用开发,系HarmonyOS NEXT智能扫描领域首批
    近期,“鸿蒙合作签约暨扫描全能王鸿蒙原生应用开发启动仪式”(简称“签约仪式”)正式举行。合合信息与华为达成鸿蒙合作,旗下扫描全能王将基于HarmonyOSNEXT正式启动鸿蒙原生应用开发。据悉,扫描全能王是鸿蒙在智能扫描领域内签约原生应用开发的头部产品,双方拟在以OpenHarmony为底座......