Use command to get a parameter and add extension

Hi,

I'd like to get something like:

Input:

my_command FILE

Output to command line:

my_command FILE.ext1 FILE.ext2

explained:
I want to provide a filename without extension and it should be given out like a command with the filename+extension1 and filename+extension2.

I'd assume this should be done simply in a shell.
Maybe anyone also knows soultions which can fulfill this as AWK/SED script?!

Thanks and best regards!

====
Edit:
Maybe I should more explain that the issue is to call the command. Should be very simple...

#!/bin/sh
echo "this shows params as wanted output: $1.log and $1.ref"
echo "-----------------------------------------------------------------------------"
echo "This is wanted outcome but as USED command, not printed only:"
echo "mycommand $1.log $1.ref"
echo "-----------------------------------------------------------------------------"
echo "Solution could be somthing like... (maybe i need `$1`or "$1" or other command as system?!)"
system("mycommand $1.log $1.ref");

Not sure...
All I can see is that your "command" is the same... but does not the same so I would imagine a first script that formats for you (correct command and output) then to not call the correct but the one that formats, you put it elsewhere and use an alias :

alias correct_command='/path_2_format_command'

Its Friday, I may not be very clear...

Demo:
With command touch:

ant:/home/vbe/wks/test $ ll
total 4
drwxrwxr-x   2 vbe        bin             96 Mar 23 15:22 .
drwxr-xr-x   4 vbe        bin           2048 Mar 23 15:19 ..
-rw-rw-r--   1 vbe        bin              0 Mar 23 15:20 file
ant:/home/vbe/wks/test $ cat ../testing
touch $1.txt $1.log
ant:/home/vbe/wks/test $ alias touch='../testing'
ant:/home/vbe/wks/test $ touch file                 
ant:/home/vbe/wks/test $ ll
total 4
drwxrwxr-x   2 vbe        bin             96 Mar 23 15:23 .
drwxr-xr-x   4 vbe        bin           2048 Mar 23 15:19 ..
-rw-rw-r--   1 vbe        bin              0 Mar 23 15:20 file
-rw-rw-r--   1 vbe        bin              0 Mar 23 15:23 file.log
-rw-rw-r--   1 vbe        bin              0 Mar 23 15:23 file.txt
ant:/home/vbe/wks/test $ 
1 Like

Not exactly what you said but you gave me the point...
the issue is, I used an alias as my_command.
So workaround is easy: replacement of the alias with the command in it.

Now it works perfect... no system needed - thanks a lot!
Most times it's easier as you think and I thought some kind of system call is needed :slight_smile:

Maybe any1 knows if and how I can use aliases in an bash script?

Putting your aliases in .bashrc does not suffice?

I would suggest more looking at using functions in your script...
Well look above example if I forget to unalias touch, I will be wondering what is going on next week...
Alias affects all your environment, using functions can be specific to an application, script (or your environment if you put them there...).