首页 > 其他分享 >[Bash] quotes

[Bash] quotes

时间:2024-06-10 14:54:55浏览次数:12  
标签:... use long echo quotes So Bash

Single quotes

If you want to use characters like < or > in the arguments to a program, you will need to use quotes so that the shell doesn't try to interpret them.

For example, to echo the string <b>wow</b> we can use single quotes:

~ $ echo '<b>wow</b>'
<b>wow</b>

Single quotes= print as it is

Double quotes

Double quotes are similar but environment variables and backticks will be interpolated in-place (replaced with their value):

~ $ echo "There's no place like $HOME."
There's no place like /home/substack.
~ $ echo "So long `date +%Y`..."
So long 2014...
~ $ echo "So long `date +%Y`... next stop $((`date +%Y`+1))"'!'
So long 2014... next stop 2015!

You will also need to use quotes if one of the arguments you want to give has a whitespace character in it, because whitespace is otherwise used to split arguments.

标签:...,use,long,echo,quotes,So,Bash
From: https://www.cnblogs.com/Answer1215/p/18240662

相关文章

  • [Bash] Environment variables
    Environmentvariablesaredefinedbytheshellandshellscripts.Tolistthecurrentenvironmentvariables,typeexport:~$exportdeclare-xDISPLAY=":0"declare-xHOME="/home/substack"declare-xHUSHLOGIN="FALSE"declar......
  • 在Linux中,什么是 BASH?
    在Linux中,BASH(BourneAgainSHell)是一个广泛使用的shell,也是大多数Linux发行版的默认shell。BASH是Bourneshell(sh)的一个替代品,由BrianFox和ChetRamey编写,以改进sh的功能和易用性。以下是关于BASH的详细解释:1.定义BASH是一个命令行解释器(也称为shell),它允许用户与操作系统进行......
  • [Bash] Backticks, xargs and Arithmetic
    BackticksUsingtoexeccmdandreturntheoutputasstring$echo`date`FriJun715:40:11EEST2024Thesameeffectyoucanachievebyusing$echo$(date)FriJun715:40:11EEST2024Examples$echo`date+%F`2024-06-07$echosomelogdata>......
  • 如何用在bash中截取部分系统参数?
    背景在编程过程中遇到一个问题。在一个bash脚本中,我需要用lame重新生成音频文件的压缩版本。原有的参数为三个:种子值、源txt文件和目标wav文件。我希望的是能够顺便自动生成压缩的mp3版本以及添加了背景音乐的版本,但是我又不希望添加新的输入参数。这样,对于原本的系统参数进行切......
  • 在Linux中,BASH 和 DOS之间的区别是什么?
    BASH(BourneAgainSHell)和DOS(DiskOperatingSystem)之间存在显著的区别,这些差异不仅体现在它们的设计哲学、功能特性上,也反映在它们所服务的操作系统环境及其用途上。以下是一些主要的区别:性质和定位:BASH:是一种命令行解释器(shell),它是用户与Linux或其他类UNIX操作系统交互......
  • bash实现当前路径下子目录跳转
    说明很早之前尝试过autojump项目,当时使用bash函数实现jc功能,最低测试过Ubuntu16.04日常中高频使用,今天使用添加了bash补全,分享给诸位配置function_j_completion(){localcur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=($(compgen-W"$(echo-n$PWD|sed's/\///g')"-......
  • [Bash] pbcopy command
    pbcopyisacommand-lineutilityavailableonmacOSthatallowsyoutocopytheoutputofacommanddirectlytotheclipboard.Itcanbeveryhandyforquicklycopyingtextortheresultsofcommandstouseelsewhere.#CopyTexttoClipboard:echo"......
  • bashrc和profile区别
    转载请注明出处:作用与目的:.bashrc:这个文件主要用于配置和自定义用户的终端环境和行为。每次启动新的终端时,.bashrc文件都会被执行,加载用户设置的环境变量、别名、函数等。这使得用户能够根据自己的喜好和需求来定制终端的行为和外观。profile(通常指的是~/.profile或/etc/prof......
  • [Bash] Calendar and Dates
    CalendarcalMay2024SuMoTuWeThFrSa12345678910111213141516171819202122232425262728293031#allmonthscal2024#first6linescal2024|head-n6#showonemonthc......
  • vue项目创建(git-bash版本)
    前言        1、安装git-bash        2、安装node.js        3、npm包管理工具安装        4、安装webpack工具        5、安装vue-cli        6、创建项目        7、问题报错解决方案前言      ......