CygWin cmd "source" and renaming with "mv" - cygwin

I am a bit curious about CygWin command source and renaming with mv.
When I run in source file cmd mv and would rename some file in my computer, it renames files well, but unhappily it puts at the end of name also the cryptic character.
f.e.: 1A6CSAB000A1_51D9.pdfand in this case, my computer isn´t able to open the file.
But when I run it without cmd source (and source file), just with
mv A.phd.1 B.phd.1
in CygWin, it works well and rename files without cryptic character.
Any idea how to deal with this issue?
Thanks in advance and sorry, if there is similar question, I didn´t find it.
Gabi

Related

Terminal Linux - referencing executable file - No such file or directory

I'm not great in the terminal, and I can't figure out why its returning this. It's probably really obvious so apologies for asking, but the executable file I'm referencing is definitely in that file path, and after researching I can't seem to find an answer:
/home/user/protoc-3.5.1-linux-x86_64/bin/protoc object_detection/protos /*.proto --python_out=.
object_detection/protos/*.proto: No such file or directory
(I can't cd into it as I need to do this in a particular directory)
Thanks
It seems bash is looking for a specific file that has the name "[star]" instead of using this as a wildcard.
I think you might need to use a pipe to get the desired result.
From your command line, it looks like protoc is the executable, located at /home/user/protoc-3.5.1-linux-x86_64/bin/protoc. And that you're giving it two arguments separated by a space: object_detection/protos and /*.proto. If you have spaces in the file path, you'll need to escape them or double-quote them:
protoc object_detection/protos\ /*.proto or
protoc "object_detection/protos /*.proto"
The odd thing is that the error message indicates differently:
object_detection/protos/*.proto: No such file or directory
Or possibly the protoc executable needs the absolute (complete) path for file arguments. If from your current working directory the command ls object_detection/protos/*.proto shows results for you, then you can try running your command like this to use absolute file paths:
/home/user/protoc-3.5.1-linux-x86_64/bin/protoc $PWD/object_detection/protos/*.proto
$PWD is an environment variable that contains your working directory path.

Linux commands within bat file - Aliasing

I seem to be having an issue.
I'm trying to write a batch file that uses Linux commands such as rm, mv, clear, and cat within a Windows batch file, but the catch is I can't seem to figure out what I need to do in order for the Windows command line to recognize that when I type in mv I want it to move a file for me, or rm to remove a file of course.
So far all I have figured out is that I could possibly use __DOSKEY__ but it doesn't work in batch files or with parameters (doh!). Thus, all I have gotten so far is:
#echo off
mv dummy.txt
Now my question is how do I get the Windows command line to recognize that mv = move ? Everytime I run the file it just gives me a blank command line.
I know this may sound stupid but my experience is more on the Linux side of the command line than the Windows side, and any help would be greatly appreciated!
Internal cmd commands cannot be aliased. For external commands, you could create hardlinks, but "move" for example is an internal command.

Rename directory in linux system

I asked 'change filename without using mv command and rename function' few days ago, and #nos answered me. So I try to use 'link' function.(It seems to create a hard link.)
But, it is not available with a directory.
Is there any way to change a directory name without using 'rename' function and 'mv' command?
I can use my copy function and delete function, but it is too hard and wasteful to just change a directory name.
I just want to know whether there is any way to change a directory name without using 'rename' function and 'mv' command.
I'm so sorry about my poor English skill... ;(...
Try this answer!
mv /home/user/oldname /home/user/newname
If you just want to rename the folder(not moving file to different folder) use below command.
mv oldFolderName newFolderName

can't source script in a current directory

So apparently, I can't source a script if that script is in the current directory. For example,
# source some/dir/script.sh
Ok
works fine, but if I'm in the same dir as the script, it errors out:
# cd some/dir
# source script.sh
-sh: source: script.sh: file not found
What gives? Is the only way around this to change directory?
I'm using bash v4.2.10 on Angstrom Linux if that's relevant.
Quoting the source man page:
source filename [arguments]
....
If filename does not contain a slash, file
names in PATH are used to find the directory containing file-
name.
So... source is trying to search your script.sh in the folders contained in PATH.
If you want to source a file in the current folder use
source ./script.sh
Use an absolute path -- source /root/path/to/some/dir/script.sh -- should sort you.
This can happen when the file is in the wrong format. I FTP'd a Korn Shell script from Windows. I could edit it, but got "not found [No such file or directory]" when I tried to run it. It turned out it was in DOS format, which was indicated in the file name line when I edited it in vi. After I re-FTP'd it, making sure it was being transferred as ASCII, it ran fine.

Tried to create symlink to Sublime Text 2

I am relatively new to linux so please be patient.
I just attempted to create a symlink to Sublime Text 2.
I can open Sublime Text 2 by typing
~/bin/sublime <filename>
however, simply typing
sublime <filename>
gives me a "sublime: command not found" error.
Can anyone explain what I am doing wrong?
This is because you installed sublime in a 'bin' directory inside your home folder. This 'bin' directory is not in your path and your shell will not find sublime there.
There are several solutions for this problem but a simple one is to add the '~/bin' directory to your path. To do this, just edit your file ~/.bashrc (suposing you are using bash) or ~/.profile (if you are using any other shell) and add the following line:
export PATH="$PATH:$HOME/bin"
Restart your shell or simply call source .bashrc
Let me know if this solves your problem and assign points (or mark as solved) if this answer helped you.
Best wishes.

Resources