首页 > 其他分享 >[Bash] Backticks, xargs and Arithmetic

[Bash] Backticks, xargs and Arithmetic

时间:2024-06-07 20:55:44浏览次数:11  
标签:xargs log Backticks echo 2024 year date Arithmetic

Backticks

Using to exec cmd and return the output as string

$ echo `date`
Fri Jun 7 15:40:11 EEST 2024

The same effect you can achieve by using

$ echo $(date)
Fri Jun 7 15:40:11 EEST 2024

Examples

$ echo `date +%F`
2024-06-07

$ echo some log data > blah-`date +%F`.log
# it creates log files blah-2024-06-07.log

arithmetic

With $((...)) expressions, you can do simple arithmetic on the command line.

$ echo $((4*5+1))
21

$ echo Greetings from the year $((`date +%Y`+1000))
Greetings from the year 3024

xargs

Read from stdin, and apply the result to next cmd, kind of like point free sytle.

$ date +%Y | xargs echo Grettings from the year
Greetings from the year 2024

标签:xargs,log,Backticks,echo,2024,year,date,Arithmetic
From: https://www.cnblogs.com/Answer1215/p/18237843

相关文章

  • 每天一个Linux命令(1):xargs
    命令简介xargs可以将stdin中以空格或换行符进行分隔的数据,形成以空格分隔的参数(arguments),传递给其他命令。因为以空格作为分隔符,所以有一些文件名或者其他意义的字符串内含有空格的时候,xargs可能会误判。简单来说,xargs的作用是给其他命令传递参数,是构建单行命令的重要组件之一。......
  • What does "xargs grep" do?
     https://askubuntu.com/questions/833128/what-does-xargs-grep-dohttps://superuser.com/questions/46199/how-to-combine-find-and-grep-for-a-complex-search-gnu-linux-find-grephttps://unix.stackexchange.com/questions/310987/how-to-use-find-and-grep-effective......
  • CodeForces 115D Unambiguous Arithmetic Expression
    洛谷传送门CF传送门直接区间dp可以做到\(O(n^3)\),卡常可过,在此就不赘述了。为了方便先把连续的数字缩成一段。我们考虑直接从前往后扫,扫的过程中dp。设\(f_{i,j}\)为考虑了\([1,i]\),还有\(j\)个没配对的左括号的方案数。但是我们发现我们不知道一个数字前要添加几......
  • 52 Things: Number 23: Write a C program to implement Montgomery arithmetic.
    52Things:Number23:WriteaCprogramtoimplementMontgomeryarithmetic.52件事:第23件:写一个C程序来实现Montgomery算术。 Thisisthelatestinaseriesofblogpoststoaddressthelistof这是一系列博客文章中最新的一篇'52ThingsEveryPhDStudentShould......
  • 52 Things: Number 22: How do you represent a number and multiply numbers in Mont
    52Things:Number22:HowdoyourepresentanumberandmultiplynumbersinMontgomeryarithmetic?52件事:数字22:在蒙哥马利算术中,你如何表示一个数字并将其相乘? Thisisthelatestinaseriesofblogpoststoaddressthelistof '52ThingsEveryPhDStudentSh......
  • Left/right arithmetic shift by 1 or 8
    Builda64-bitarithmeticshiftregister,withsynchronousload.Theshiftercanshiftbothleftandright,andby1or8bitpositions,selectedbyamount.Anarithmeticrightshiftshiftsinthesignbitofthenumberintheshiftregister(q[63]inth......
  • ps xargs 和kill 一行结束进程
    前言全局说明一、当前状态有一个进程77463需要结束二、ps和killps-ef|greppython3817|grepmain.py|kill-9`awk'{print$2}'`ps-ef|greppython3817|grepmain.py:找到要结束的进程awk'{print$2}':以空格为分割符,获取第2列内容,既77463进程号kill-9......
  • Linux命令-xargs
    声明:本文框架和思路均参考阮一峰博客的xargs命令教程xargs通常用于将A命令的输出作为B命令的输入(参数),因为一些命令的参数无法使用标准输入(stdin)而只能使用命令行对于那些可以使用stdin作为参数的命令,我们并不需要xargs,直接使用|即可如cat/etc/shells|grepbash而对于不支......
  • CF710D Two Arithmetic Progressions 题解
    CF710DTwoArithmeticProgressions根号分治薄纱数论看日报学习的根号分治:暴力美学——浅谈根号分治-paulzrm的博客。开始想学ODT的映射思想的推广-金珂拉的博客,结果先学了ODT,又学了根号分治,才搞懂前置知识。什么是根号分治根号分治,是暴力美学的集大成体现。与......
  • 关于 ‘--exec’ 参数( find 命令)及介绍 ‘xargs ’命令区别
    findgoal.log.*.gz-mtime+2-execrm-rf{}\;findgoal.log.*.gz-mtime+3|xargsrm-f前言:find命令一直都是系统管理员的常用命令之一,其参数中“-exec”尤其实用。而“xargs”命令,针对查询也有属于自己的见解。本文着重讲解的是围绕find命令查询为主线,使用-exe......