Skip to main content

All Questions

Tagged with
0 votes
1 answer
71 views

Is there a way I can use .bash_aliases in a shell-scripts? [duplicate]

Is there a way I can use bash aliases from my .bash_aliases file within a shell-scripts? I thought of something like including source "$HOME/.bash_aliases into my script but it does not work.
nath's user avatar
  • 6,074
0 votes
1 answer
404 views

How to show help for some bash command in less (like man do) rather than print it to console

For example, there is no manual pages for trap command. Running: man trap will give: No manual entry for trap Running: trap --help will print help straight to bash console without using less like ...
Anton Samokat's user avatar
1 vote
1 answer
547 views

Unix Command (and bash alias) or script to band/unban IP addresses in Fail2ban without having to lookup and specify "jail name"

I am creating a bash alias (or possibly a script) to ban and unban IP addresses with fail2ban on Ubuntu 20.04. The bash syntax I am using to unban IP address is: fail2ban-client set YOURJAILNAMEHERE ...
DanRan's user avatar
  • 113
2 votes
0 answers
326 views

Order in which files within /etc/profile.d are sourced in CentOS 7.9? (for defining aliases)

I have a question related to aliases/environment variables on CentOS 7.9. I am trying to make an alias for ll with: echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/Z-alias-ll.sh ...
Tristan's user avatar
  • 121
1 vote
1 answer
153 views

use aliases in bash script

I use aliases in my code, it works the first time and shows the current time, but the second time, when I call it shows past time(time showed before instead of current time) GNU nano 6.2 ...
Milad Alkhamis's user avatar
1 vote
0 answers
330 views

Minify bash command with arguments

Want to minify bash command using arguments. I am often checking the internet provider's and other Free and Public DNS Servers with the code below running in tmux, but wondering, how this can be ...
eapo's user avatar
  • 121
1 vote
3 answers
4k views

How do I make an alias for a command with sudo

I want to add two aliases, so one executes a command when non sudo, and the other executes a command when sudo, like this: alias v = 'nvim' alias 'sudo v' = 'sudo -E nvim ' I also have set alias sudo=...
Ramita's user avatar
  • 11
-1 votes
1 answer
1k views

bashrc + why source not refresh the .bashrc file

we add the following line to bashrc file alias reboot="echo you not allowed to do reboot on this machine - sorry" so we get more ~/.bashrc # .bashrc # User specific aliases and functions ...
yael's user avatar
  • 13.9k
1 vote
1 answer
765 views

How to evaluate bash alias before being passed to bash function?

I have defined a test alias as: alias testalias='python3 -c "f = open(\"/tmp/testopenfile\", \"w+\"); f.write(\"hi\n\")"' It works fine when I run it directly ...
Machinexa's user avatar
  • 143
-2 votes
2 answers
611 views

Kali Linux - run './pycharm.sh' by running 'pycharm' in terminal

Currently I need to access the folder in my desktop, and then a bin subfolder to reach ./pycharm. So I want to automate all of: cd Desktop cd pycharm-community-2021.3.1 cd bin ./pycharm.sh to pycharm ...
ThomasReiner's user avatar
0 votes
2 answers
213 views

Is escaping shell aliases in scripts useful when executing scripts?

Does escaping bash aliases make any sense in any - not sourced and normally run - shell scripts? Consider the simplest situation with ls for which many users have re-defined its functioning with an ...
Vlastimil Burián's user avatar
1 vote
1 answer
241 views

How to set an environmental variable from another script?

I set a variable WORKSPACE="$(git rev-parse --show-toplevel)" in ~/.bashrc - which essentially sets $WORKSPACE to the root of the git repository so that I can write alias for some of the ...
Darshan L's user avatar
  • 279
-1 votes
1 answer
64 views

How to make .bashrc alias that runs an .sh file containing a second alias, and then runs that second alias?

Is it possible for me to do what is described in the title? Lets say I have a script "initstuff.sh" and within that script there is an alias "shalias" that runs some stuff. Putting ...
Justin Finkelstein's user avatar
1 vote
2 answers
2k views

How to make bash alias work with command inclusion i.e. $() (the dollar sign and parenthesis)

I used to have aliases like: alias mount-open="sudo mount $(sudo blkid | gawk '/2tb-open/ { print substr($1, 0, 9) }') 2tb-open" I can't be 100% sure that it was the same, but 100% it was a ...
d.k's user avatar
  • 297
3 votes
1 answer
3k views

alias inside a script returns command not found

Using bash in a Debian system. bash --version GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later &...
gogasca's user avatar
  • 195

15 30 50 per page