I have tested hostname on several servers (RedHat, Ubuntu), and hostname -f has proven unreliable, returning sometime the short name only (as described in this question).
I can see the fqn in the aliases: hostname -a (one of the aliases is the fqn I look for), but the order of the aliases is not fixed.
Is there another way to get the fully qualified name reliably, and store it in a bash variable
I am writing a bash script that runs each of its arguments as a command. This works for commands in my PATH, but not for aliases. I can directly call an alias in the script, but I can't call an alias that has been passed as an argument.
The problem (I assume) is that aliases are expanded before variables.
When I log in to my Ubuntu 12.04 LTS server my bash aliases aren't applied, but if I execute bash from the command line they are.
~/.profile executes ~/.bashrc:
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
, which in turn executes ~/.bash_aliases:
if [ -f ~/.bash_aliases ]; then
.
I've been scratching my head over this one for a while now. It seems so simple yet I just can't get it to work. This is on a rooted android tablet, if that makes a difference. I'm trying to imitate the behavior of sudo on a normal linux system. I'm not very experienced when it comes to bash scripting, so this is probably very simple.
I'm still kind of new to the *nix world, so please excuse the "noobishness" of the question.
What I essentially want to know is the difference between aliases and functions in the bash shell - and when to use which one.
It seems obvious that since functions can take arguments, they are a lot more powerful - since I work mainly on the road with a netbook and want to save energy and processing powe
What is the correct places to put bash aliases which should be available for everyone?
I want to set it up in such are a way that if some aliases are not available for somebody, it is because they overrode it themselves in their own settings.
Hi,
I'm trying to remove duplicate MP3 files from a iTunes library of around 15,000 tracks with about 10,000 duplicates.
The duplicates all have the suffix ' 1.mp3', e.g.
Music/artist/album/tracka.mp3
but there also exists
Music/artist/album/tracka 1.mp3
I'd like to remove all the files with the suffix ' 1.mp3' iff the file without the ' 1' suffix exists in the same directory.
It's taken me almost 10 years of Linux usage to ask this question. It was all trial and error and random late-night internet surfing.
But people shouldn't need 10 years for this. If I were just starting out with Linux, I'd want to know: When to alias, when to script, and when to write a function?
Where aliases are concerned, I use aliases for very simple operations that don't take arguments.
Synopsis
eval: eval [arg ...]
Description
eval takes its arguments, concatenates them, and executes the resulting string as Bash code in the current execution environment. eval in Bash works in essentially the same way as most other languages that have an eval function.