The options tag has no wiki summary.
26
votes
7answers
3k views
How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)?
How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory:
tohru:~ $ ls -l
total 8
-rw-r--r-- 1 me ...
21
votes
7answers
2k views
why does ls -d also list files, and where is it documented?
when specifying ls --directory a* it should list only directories starting with a*
BUT it lists files AND directories starting with a
Questions:
where might I find some documentation on this, ...
17
votes
2answers
450 views
What is `--` called?
Recently I got to know of -- that is double-hyphen which is used to tell a command that the option list has ended and what follows should not be considered as a option. So,
grep -- 'search_word' *
...
15
votes
2answers
4k views
tar cvf or tar -cvf ?
I have learned to use tar without '-' for options, like tar cvfz dir.tar.gz Directory/ but I recently came accross the slightly different tar -czvf syntax (I think the 'f' must be the last option in ...
10
votes
4answers
559 views
Single dashes `-` for single-character options, but double dashes `--` for words?
Where did the convention of using single dashes for letters and doubles dashes for words come from and why is continued to be used?
For example if I type in ls --help, you see:
-a, --all ...
9
votes
5answers
3k views
Compiling GNU/Linux with -O3 optimization
It's said that compiling GNU tools and Linux kernel with -O3 gcc optimization option will produce weird and funky bugs. Is it true? Has anyone tried it or is it just a hoax?
8
votes
3answers
880 views
Is there a 'rc' configuration file for grep/egrep? (~/.egreprc?)
I usually do some grep when developing, and there are some extensions that I always don't want to look for (like *.pyc).
Is it possible to create a ~/.egreprc or something like that, and put some ...
6
votes
4answers
2k views
How do I handle switches in a shell script?
Are there some built-in tools that will recognize -x and --xxxx as switches, and not arguments, or do you have to go through all the input variables, test for dashes, and then parse the arguments ...
6
votes
3answers
304 views
What's the purpose of `rm -P`?
I was reading the man page for rm when I came across this option:
-P Overwrite regular files before deleting them. Files are overwritten
three times, first with the byte pattern 0xff, then ...
6
votes
3answers
322 views
getopt, getopts or manual parsing - what to use when I want to support both short and long options?
Currently I'm writing a Bash script which has the following requirements:
it should run on a wide variety of Unix/Linux platforms
it should support both short and (GNU) long options
I know that ...
5
votes
4answers
427 views
How can I create a empty file whose name begins with a dash?
How can we create a empty file with the unix name -stuff.
It means the name start with -. I tried with touch -stuff but it didn't work.
5
votes
1answer
202 views
In the usage string of my custom shell script, shall I also display --help and --version?
I'm currently developing a shell script, called up, which shows a usage string on the commandline when called with --help. The output looks like this:
$ up --help
usage: up [-n ...
5
votes
2answers
67 views
Handling an option-like filename in the shell [duplicate]
Possible Duplicate:
How do I delete a file whose name begins with "--"?
Due to mismatched switches when I was trying to run a command, I have a log file named -w in a directory. I ...
5
votes
1answer
113 views
Handling filenames that contains a hyphen, within a script
I have few files that was incorrectly encoded, during extraction, file names now become something similar to -a -b,
Now I'm trying to fix this issue with:
convmv -f ENCODING -t utf8 --notest *
But ...
4
votes
3answers
494 views
Remove many many many files from a folder
I have a folder with 137795 files in it. I need to delete all of them. When I run rm * I get -bash: /bin/rm: Argument list too long. How do I get past this error?
4
votes
2answers
2k views
what is commit=0 for ext4? does mdadm not support it?
I see this in my dmesg log
EXT4-fs (md1): re-mounted. Opts: commit=0
EXT4-fs (md2): re-mounted. Opts: commit=0
EXT4-fs (md3): re-mounted. Opts: commit=0
I think that means that dealloc is disabled? ...
4
votes
1answer
101 views
If I'm logged in as root, how do I restart mysql or apache with options?
I know the commands to restart/stop/start, but when I try to pass options it doesn't seem to work!
CENTOS 6, MySQL 5.14
service mysql restart
service httpd restart
Then I tried this:
...
3
votes
2answers
774 views
Download list of files if they don't already exist
If I have a list of URLs separated by \n, are there any options I can pass to wget to download all the URLs and save them to the current directory, but only if the files don't already exist?
3
votes
2answers
241 views
Is it possible to disable verbose in the middle of running?
I am running a program fls (from the Sleuth Kit) with option -v for verbose mode. However it takes too long, and the program is still running since yesterday. I guess it will run faster without ...
3
votes
2answers
1k views
How to catch optioned and non optioned arguments correctly?
I want to write a shell script which will take some arguments with some options and print that arguments. Suppose the name of that script is abc.ksh. Usage of that script is -
./abc.ksh -[a ...
3
votes
1answer
79 views
Understanding grep --label=
I am looking for an explanation how grep --label=LABEL works: Maybe somebody can give me an example [or two] on what --label= is for.
I understand what grep and zgrep are supposed to do – the ...
3
votes
2answers
653 views
How can I detect that no options were passed with getopts?
I have this code -
#getoptDemo.sh
usage()
{
echo "usage: <command> options:<w|l|h>"
}
while getopts wlh: option
do
case $option in
(w)
name='1';;
...
3
votes
1answer
1k views
xmessage over ssh
The following command prints a message over ssh :
xmessage Message -display :0 &
How does it work? there is no -display option in xmessage's man page.
3
votes
2answers
267 views
Getopts option processing, Is it possible to add a non hyphenated [FILE]?
I'm using getopts for all of my scripts that require advanced option parsing, and It's worked great with dash. I'm familiar with the standard basic getopts usage, consisting of [-x] and [-x OPTION]. ...
3
votes
1answer
703 views
What does Linux's “nointremap” option do?
Ubuntu 12.10 alpha 2 works perfectly on my new 11" 2012 Macbook Air, but only when I boot with the "nointremap" option. Supposedly this is not good to use as a permanent solution. What exactly does ...
2
votes
2answers
132 views
List of available command options?
I'm currently setting up my first web server without a control panel and so far things are going pretty good!
I was just wondering if anyone could direct me to somewhere that explains all of the ...
2
votes
1answer
228 views
How to find every symbolic link on a server?
I need to find every symbolic link on the server.
The version is AIX 6.1.
man find says
-L Follow symbolic links
But find -L is not a proper usage. Usage: find [-H | -L] Path-list ...
2
votes
1answer
238 views
What is the `less` command line option to page to the next file at the end of the current one?
I'm sure there used to be an option in less which allowed you to page onto the next file after you reached the end of the current file, so you could just keep *space*ing through a bunch of short files ...
2
votes
1answer
606 views
Altering the default boot option on CentOS
I recently installed a copy of CentOS onto my main hard drive (I now have Windows 7 and CentOS). Whilst installing CentOS, I accidentally set it to be the main boot option, so when I start my PC I ...
2
votes
1answer
1k views
How to run a specified codeblock with getopts when no options or arguments are supplied?
So I am writing a script that mixes options with arguments with options that don't. From research I have found that getopts is the best way to do this, and so far it has been simple to figure out and ...
1
vote
4answers
306 views
What is this Bash line supposed to mean?
find . -name "*.html" -exec grep -l somethingtobefound {} \;
I was just wondering what the keywords "-name" "-exec" "-l" "{}" "\" and ";" were supposed to signify.
Also, I commonly see ...
1
vote
1answer
119 views
What is the canonical way to implement order independent options in bash scripts? [duplicate]
Possible Duplicate:
How do I handle switches in a shell script?
Most common shell commands allow the user to specify options in any random order. Positional Parameters like $1 as commonly ...
1
vote
2answers
24 views
mount defaults and various filesystems
I read on the man page
defaults
Use default options: rw, suid, dev, exec, auto, nouser, async, and relatime.
Do the options set depend on a mounted filesystem or not?
1
vote
2answers
323 views
How to change a firefox option on a quick way (via shortcuts, command line,..)?
In Firefox we have two options at Firefox->Preferences->Preferences->Fonts and colors->Colors menu, Use system colors and Sites can use other colors.
I would like keep the first one ...
1
vote
1answer
47 views
mplayer -msglevel all=-1 doesn't make it completely silent!
I'm trying to open mplayer to play video without any terminal output using this:
mplayer -msglevel all=-1 /path/to/video
also:
mplayer -really-quiet /path/to/video
but it doesn't make it ...
1
vote
0answers
139 views
Processing shell script options with awk
I'm looking for way to process shell script arguments that is cleaner and more "self documenting" than getopt/getopts.
It would need to provide...
Full support of long options with or without a ...
0
votes
1answer
138 views
How does “options” in shell scripting work?
I found some code in one of the answers here and accommodated it to my needs but now I have two questions:
Q1: how can I display the options text after the code in case statement finishes? So the ...
