alias testing="date | tee /home/anupamkhatiwada/fulldate.txt | cut --delimiter=" " --field=1 | tee /home/anupamkhatiwada/shortdate.txt | xargs echo hello"
On typing test in terminal and pressing enter getting
testing: command not found
alias testing="date | tee /home/anupamkhatiwada/fulldate.txt | cut --delimiter=" " --field=1 | tee /home/anupamkhatiwada/shortdate.txt | xargs echo hello"
On typing test in terminal and pressing enter getting
testing: command not found
Probably because you have embedded " in your string. Try this instead:
alias testing='date | tee /home/anupamkhatiwada/fulldate.txt | cut --delimiter=" " --field=1 | tee /home/anupamkhatiwada/shortdate.txt | xargs echo hello'
When I run that command I get this error message:
-bash: alias: ` --field': invalid alias name
And as PaulProgrammer pointed, seems to be due to the delimiter character used in your cut command, the double quotes ", which conflicts with the ones used to define the alias. Hence, another workaround would be:
alias testing="date | tee /home/anupamkhatiwada/fulldate.txt | cut --delimiter=' ' --field=1 | tee /home/anupamkhatiwada/shortdate.txt | xargs echo hello"
Define a function instead of an alias, then you don't have to worry about quoting conflicts.
testing() {
date | tee /home/anupamkhatiwada/fulldate.txt | cut --delimiter=" " --field=1 |
tee /home/anupamkhatiwada/shortdate.txt | xargs echo hello
}
Functions have the added benefit that they can take parameters, which can be inserted in the middle of the commands. See Make a Bash alias that takes a parameter?