Running files using the * command in linux [closed] - linux

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)

Related

What does rm ** does in LINUX [closed]

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.

Meaning of different indicators when using 'ls -F' [closed]

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 4 years ago.
Improve this question
I'm currently studying Bash shell and have encountered command ls -F. I know it ls function is to append indicators to items lists, so to distinguish between different file types. I know that / is appended to directory and * is appended to executable files. But I have checked the manual page on ls command but couldn't find any information on indicator =>#|.
Could someone tell me what they represent? And it would be even better if can inform me where to find this kind of information when in need.
Try info ls, under "What information is listed":
‘-F’
‘--classify’
‘--indicator-style=classify’
Append a character to each file name indicating the file type.
Also, for regular files that are executable, append ‘*’. The file
type indicators are ‘/’ for directories, ‘#’ for symbolic links,
‘|’ for FIFOs, ‘=’ for sockets, ‘>’ for doors, and nothing for
regular files. Do not follow symbolic links listed on the command
line unless the ‘--dereference-command-line’ (‘-H’),
‘--dereference’ (‘-L’), or
‘--dereference-command-line-symlink-to-dir’ options are specified.

How to limit terminal output of a bash command in a script [closed]

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
(EDIT)
I am creating a bash program that has many fully featured options as a networking program written in python. In my program, I am using the below command and it's specific output will be used as a variable.
I am looking for a command or method to display only specific terminal output of a command. For example if, in my script, I use the command:
iwconfig wlan0
Yet all I wish to see from this command is what mode in which wlan0 is set. (i.e. Master, Managed, Monitor, etc.)
I have looked and searched all over Google and Bash specific sites and cannot find a solution. I may be overlooking something.
The grep option you're looking for is -o, or --only-matching in its long form. It outputs only text that matches the search you gave it, and nothing else. For example:
iwconfig wlan0 | grep -o 'Mode:[^ ]*'
outputs Mode:Managed on my machine. The single quotes are necessary so that the shell won't try to interpret the [, ] and * characters (with double quotes, if you happened to have a file with precisely the wrong name in your current directory, the shell might wrongly expand your parameter to the name of that file). The regular expression inside the single quotes means "the text Mode:, followed by any number of non-space characters", which is exactly what you were looking for.

How to delete file named "-d" in unix(Mac OSX) from command line? [closed]

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

Unix command for picking out run commands [closed]

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 9 years ago.
Improve this question
I am relatively new to linux environment. My doubt is this:
I run a lot of commands of various types , so when ever i want to rerun a old one i have to look through the entire history. is there any bash command that displays just the commands that begin with a particular combination of characters( my case here is i just want a list of all the ./ eg: ./ifv_script , ./run_regression i've run from the terminal)
Three methods:
You can grep your current history, e.g.:
$ history | grep ifv
You can also recall commands from the history by typing ControlR and then type a few characters from the command.
Finally you can grep your saved history file for older invocations from previous sessions, e.g.:
$ grep ifv ~/.bash_history
Just press Ctrl+R, and you will enter into reverse-i-search mode.
Now you can type a few characters that appear anywhere in the command and bash will start finding matches.
Final approach (bash only):
history | grep term

Resources