Skip to content
Advertisement

Tag: shell

Escaping Backslashes and Double Quotes in zsh Alias

I am trying to create an alias that should turn into the following command: It’s straightforward to just do on bash, but on zsh, the command turns into I can’t get the ” or the to escape. Answer It looks like you’re treating the first and last double-quotes as ‘surrounding’ quotes for the entire expression, but that’s not how

How to replace ‘>> $log_file 2>&1’ from all files

In my files commands are like : File1.sh: File2.sh File3.sh I am looking for a command to remove the line where defined variable ‘log_file’ from all the files AND remove only ‘>> $log_file 2>&1’ part from all the files Output in files: File1.sh: echo -e “n Output is n” File2.sh File3.sh I tried multiple ways with sed but nothing worked,

Can we store “cd ..” path in a variable in bash file?

I am new to the bash my use case is to store the one previous directory in to a variable. Example: How can we add /local/ to any variable like $PREV? Answer You can use parameter expansion on $PWD which contains the current path: Or, use an external tool like readlink with command substitution:

Advertisement