Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 12 months ago.
Improve this question
what does rm ** do in linux.
started learning linux and stuck here.
I tried reading but couldnt understand or didn get the answer
* is a wildcard. Wildcard characters are used to define the pattern for searching or matching text on string data in the bash shell.
The shell interprets certain characters in filenames and for other purposes as well. It passes the interpreted version to commands. For example, the most commonly used special character is asterisk, * , meaning "zero or more characters". When you type a command like ls a* , the shell finds all filenames in the current directory starting with a and passes them to the ls command.
Since rm is to remove, rm ** will delete all the files from where you run the command.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I try
ls */ | grep "\.txt$"
to find all .txt file in the subdirectory but it seems that it can't work well all the time.
The pattern you want can easily be matched with a single glob:
ls */*.txt
The ls isn't necessary; it just demonstrates that it works. You can also use
echo */*.txt
printf '%s\n' */*.txt
files=( */*.txt )
for f in */*.txt; do ....
The pattern itself (*/*.txt) will expand to the list of the matching files; what you can do with that list is fairly broad.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
On Linux when I want to execute some file and use relative path.
For example I want to do something like this:
cd c:\windows
c:\windows>./System32/ipconfig.exe
However what I get is an error message telling me that "." has not been found.
A period denotes the current directory in Windows.
For your example you would use the following:
c:\> cd c:\windows
c:\Windows> .\System32\ipconfig.exe
Alternately, you could forego the .\ and do it like this:
c:\Windows> System32\ipconfig.exe
Use the correct slash marks and you should be good. Windows uses backslashes as the directory symbol instead of the forward slash.
The only caveat to this is if you have to change drive letters. The cd command will change the working directory, but not the drive. To change drives use [drive letter][colon]:
C:\Windows>cd P:\XenApp\Utils
C:\Windows>P:
P:\XenApp\Utils>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Let's say I wish to run all the scripts in a directory. If I do ./*.sh, which order will they run in?
Directory:
1.sh
2.sh
3.sh
To run all the scripts, you must run them separately:
for f in ./*; do
"$f"
done
The pattern will produce an alphabetically sorted list of scripts, where "alphabetical" is defined by your current locale.
Your attempt:
./*
would expand to a list of matching files, which the shell would then treat as a single command. The first script would be executed, with the remaining script names passed as arguments to the first.
They are alphabetically sorted. From the bash manual:
After word splitting, unless the -f option has been set (see The Set Builtin), Bash scans each word for the characters ‘*’, ‘?’, and ‘[’. If one of these characters appears, then the word is regarded as a pattern, and replaced with an alphabetically sorted list of file names matching the pattern.
However, in order to run them as you expect, you'll need to read #chepners answer (Thanks!, I must admit that I wouldn't expected that)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
Your system has 2 versions of the same utility installed, both which have the same filename.
How would you find out where the utility you would run by default is located?
If the utility's file name is "foo", type which foo
You'are looking for which command
which - shows the full path of (shell) commands.
Let's say you have perl installed in /usr/bin/perl and /usr/local/bin/perl and if the default path is the second one then
$ which perl
/usr/bin/local/perl
Check the $PATH.
echo $PATH
The first is started default.
or
which
Similar to which , whence gives you whence command from Korn Shell tells how a name would be interpreted by the shell: it detects commands and aliases, and searches your path.
whence {executable-you-are-looking-for}
and also in linux, just typing name & hitting tab will show list of available versions with which you can run.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I was playing with tail, head, cut and awk commands on a text file and somehow these commands created empty files with names "-d" and "-f2" (It could be due to ). Now I am not able to delete these files from command line since all commands take these as options. Of course I can delete these from Finder but I am wondering how to delete these from command line.
Use -- to separate the files from the command line arguments. That is
rm -- -d -f2
Or, you can use the full path or a relative path containing at least a /:
rm ./-d ./-f2