Score:0

Create an alias that takes a file name as a paremeter, removes the extension of the parameter and creates a new extension

us flag

I want to create an alias in my ~/.bashrc file that takes a file as a parameter, removes the extension of that file, and adds a new extension.

For instance, instead of doing cp file.txt file.bak, I would do backup file.txt with the same result (obviously this is a silly example, not what I really want to do).

So I added this line in my ~/.bashrc file:

alias backup='cp $1 ${1%???}bak'

which should work, but it doesn't. Any idea of what I'm doing wrong? Thanks.

tecate avatar
us flag
It does. Thank you very much.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.