Can't create file in Bash on MinGW64 - windows

Having an executable file in a directory, let's say named hello.exe:
$ ls
hello.exe*
The file name is colored green and an asterisk is appended.
Listing the file explicitly by giving its name but without extension, it is listed without extension:
$ ls hello
hello*
Until here it looks just like a funny feature for Win freaks that like to omit the .exe extension.
But now, when you try to create a file without any extension, Bash complains:
$ echo hello > hello
bash: hello: Permission denied
The same problem arises when you try to copy a folder structure recursively which contains a folder hello/ and an executable hello.exe in the same folder:
It cannot be copied using cp -r when (by accident) the file hello.exe is copied first and the folder hello/ is copied second; the creation of the folder is denied in this case:
cp: cannot overwrite non-directory './hello' with directory './hello'
Now my question is:
Is this a bug or a feature? If it is a feature, how can I disable it?
The system I'm using is a MINGW64 Bash on Windows 10.

Related

Command not found in ssh but is in direcory

I am using an ssh account that connects to an external server, i have downloaded through guix some software like samtools and bedtools but when i try to use them in my directory it gives me this error:
-bash: samtools: command not found
In my direcory, however, there is the directry guix.profile and if I go into the bin folder of this, I have everything I downloaded.
What am I doing wrong?
Thank you
enter image description here
To run a file from the shell you need two things:
The shell must find the file
Being in the same directory does not enable the shell to find the file. You have to either supply an absolute or relative path the file, or have the directory in your PATH environment variable
In simplest terms this means instead of
$ samtools
try
$ ./samtools
The relative path tells the shell it wants that file
To run it from another directory, either use the whole absolute path, e.g. /home/yourname/samtools , or move the file into a directory that is on your $PATH
The file needs to be executable
If the file is not executable you will need
$ chmod +x ./samtools

Why ubuntu terminal unable to find file or directory?

I'm using Ubuntu 20.4.05 LTS. It is not locating any directory as you can see in the image. For example, cd ~/Downloads doesn't take me to the directory.No such file or directory image What should I do?
as a first step you must know the position of the directory by writing the command pwd
pwd
then you can write the ls command to see the contents of the list of folders or directories
ls
if the file you need is in that directory, you can enter that file by writing the command cd
cd
access folder

Getting permission denied while creating a directory and how to add suffix to .exe to each files in a directory

I want to create a directory say source_dir and add few dummy files without content into this directory like file1.txt, file2.sh, etc
Now I want to create another directory say destination_dir and move all the files from source_dir to destination_dir but all the files that got moved from source_dir should be suffixed by .exe
Example:
source_dir
file1.txt file2.sh
destination_dir should have output as
file1.txt.exe file2.sh.exe
What I have tried :
I used mkdir source_dir -> But getting error cannot create directory. Permission denied.
touch file1.txt file2.sh -> I thought to use this command to create the files without content but not able to create a directory itself.
Once error is resolved and files are created in source_dir then I will use
mv .* source_dir destination_dir -> To move all the files at once but for this command I am not sure whether this will work or not
Then how to suffix all the files with .exe is also challenging to me and got stuck.
Can someone help me resolving the error of create directory and how to add suffix to each files?
I used mkdir source_dir -> But getting error cannot create directory. Permission denied.
It seems you do not have permission to create a fodler here. You might use sudo mkdir source_dir, but is likely a better idea to make the folder in a directory where you have write access EG. $HOME.
Once error is resolved and files are created in source_dir then I will use mv .* source_dir destination_dir -> To move all the files at once but for this command I am not sure whether this will work or not
For moving use mv .* destination_dir from withing the source_dir. (IE, first cd source_dir then run the move command from above)
Then how to suffix all the files with .exe is also challenging to me and got stuck.
You will have to loop over the files and move them one by one.
for i in * ; do mv "$i" "${i}.exe" ; done

What happens when you try to move a file to a non-existant location MAC?

On executing the following lines via the terminal on a MAC,
mv terraform2 ~/bin
cd ~/bin
I get the error that '/Users/myname/bin: Not a directory`. However, I can't see the file terraform2 in its original location. Where did it go?
Given
mv terraform2 ~/bin
If ~/bin doesn't exist before you run that command, your file terraform2 will be renamed to a file called ~/bin.
Thus, when you try
cd ~/bin
you get
/Users/myname/bin: Not a directory
because it's a file - your original terraform2 file.
The command
mv terraform2 ~/bin/.
is much better when you're trying to mv a file into a directory.

unzip .bin file programatically in ruby

I have a .bin which i am trying to unzip programatically. The directory is a temp directory in which the.bin file is saved.
I have tried to the following
change the permission of bin files by typing.
chmod -c 777 filenam.bin.
now run the bin file by typing
here is a ruby code which i have
%x(gunzip #{label_path})
using above gunzip gives me this error
unknown suffix -- ignored
I shows error as illegal option c.
Can anyone help. Thanks.
gunzip has an option -S to specify a suffix of the file to be unzipped:
gunzip -S .bin filenam.bin
The above will produce file filenam in the same directory.

Resources