Where m flag and o flag will be stored in Linux
At last I found the way. Thanks to Google, Thanks to Shirley Ma. Please get the code from my blog http://kumaran127.blogspot.jp/2013/05/get-m-and-o-flag-of-most-recently.html
What does the GNU makefile flag -m mean, and how does it operate in the line Obj -m += simple.o?
That is a Linux kbuild makefile for an out-of-kernel-tree module. As @MadScientist has pointed out your first line should read
obj-m += simple.o
In Linux kbuild context this means "compile and link simple.c to the module". The goal all
(default goal) will build the module against the kernel version you are currently running on.
NOTE: you'll need to install the kernel development headers in order for the module build to succeed.
EDIT: inside the Linux kernel tree you'll also find the notation obj-y += X
which means "compile and link X into the kernel when this kernel config has been enabled".
Meaning of python -m flag
If you type python --help
You get
// More flags above
-m mod : run library module as a script (terminates option list)
// and more flags below
A great many things in a terminal will show you how to use it if you either use command --help
or man command
In Bash, how can option flag values be stored in variables?
Use getopts.
#!/bin/bash
while getopts ":a:" opt; do
case $opt in
a)
echo "-a was triggered, Parameter: $OPTARG" >&2
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
How do i use -M flag to load a perl module using its relative path from command line?
If you have an absolute path and you want all scripts to find the module:
export PERL5LIB="${PERL5LIB:+"$PERL5LIB:"}/path/to/lib" # In your login script.
script
If you have an absolute path and you want one execution of a script to find the module:
PERL5LIB="${PERL5LIB:+"$PERL5LIB:"}/path/to/lib" script
If you have a module that's installed in a directory relative to a script:
use FindBin qw( $RealBin );
use lib "$RealBin/../lib";
In your specific case:
perl -Mlib=/sub1/sub2 -Mdemo -e'demo::doit("arg1")'
Avoid using -I
. It doesn't include related arch dirs like PERL5LIB
and lib.pm do, so modules with arch-specific components will fail to load.
Is there a way to look for a flag in a man page?
rici's helpful answer explains the problem with the original approach well.
However, there's another thing worth mentioning:
man
's output contains formatting control characters, which interfere with text searches.
If you pipe to col -b
before searching, these control characters are removed - note the side effect that the search results will be plain-text too.
However, grep
is not the right tool for this job; I suggest using awk
as follows to obtain the description of -O
:
man gcc | col -b | awk -v RS= '/^\s+-O\n/'
RS=
(an empty input-record separator) is an awk idiom that breaks the input into blocks of non-empty lines, so matching the option at the start of such a block ensures that all lines comprising the description of the option are returned.
If you have a POSIX-features-only awk
such as BSD/OSX awk
, use this version:
man gcc | col -b | awk -v RS= '/^[[:blank:]]+-O\n/'
Obviously, such a command is somewhat cumbersome to type, so find generic bash
function manopt
below, which returns the description of the specified option for the specified command from its man
page. (There can be false positives and negatives, but overall it works pretty well.)
Examples:
manopt gcc O # search `man gcc` for description of `-O`
manopt grep regexp # search `man grep` for description of `--regexp`
manopt find '-exec.*' # search `man find` for all actions _starting with_ '-exec'
bash
function manopt()
- place in ~/.bashrc
, for instance:
# SYNOPSIS
# manopt command opt
#
# DESCRIPTION
# Returns the portion of COMMAND's man page describing option OPT.
# Note: Result is plain text - formatting is lost.
#
# OPT may be a short option (e.g., -F) or long option (e.g., --fixed-strings);
# specifying the preceding '-' or '--' is OPTIONAL - UNLESS with long option
# names preceded only by *1* '-', such as the actions for the `find` command.
#
# Matching is exact by default; to turn on prefix matching for long options,
# quote the prefix and append '.*', e.g.: `manopt find '-exec.*'` finds
# both '-exec' and 'execdir'.
#
# EXAMPLES
# manopt ls l # same as: manopt ls -l
# manopt sort reverse # same as: manopt sort --reverse
# manopt find -print # MUST prefix with '-' here.
# manopt find '-exec.*' # find options *starting* with '-exec'
manopt() {
local cmd=$1 opt=$2
[[ $opt == -* ]] || { (( ${#opt} == 1 )) && opt="-$opt" || opt="--$opt"; }
man "$cmd" | col -b | awk -v opt="$opt" -v RS= '$0 ~ "(^|,)[[:blank:]]+" opt "([[:punct:][:space:]]|$)"'
}
fish
implementation of manopt()
:
Contributed by Ivan Aracki.
function manopt
set -l cmd $argv[1]
set -l opt $argv[2]
if not echo $opt | grep '^-' >/dev/null
if [ (string length $opt) = 1 ]
set opt "-$opt"
else
set opt "--$opt"
end
end
man "$cmd" | col -b | awk -v opt="$opt" -v RS= '$0 ~ "(^|,)[[:blank:]]+" opt "([[:punct:][:space:]]|$)"'
end
Unknown open() flag passed by execve()
/usr/include/linux/fs.h:
/* File is opened for execution with sys_execve / sys_uselib */
#define FMODE_EXEC ((fmode_t)32)
Related Topics
Insufficient Permission Pushing to Git Shared Repo Over Smart Http
Why 'Read' Command in Shell Script Is Missing Initial Characters
Goroutine in Io Wait State for Long Time
To What Extent Can One Rely on Writing to Disk When Sigterm Is Given
Trouble with Installing Nloptr by Locally on Ubuntu
How to Run .Exe Executable File from Linux Command Line
Sed to Loop Through File and Replace Placeholder Variables
Aborting a Blocking Read on Linux
Svn Setup of Existing Directory
Detect If Interface Is in Promiscuous Mode with C
Arm-Linux-Gnueabi Compiler Options
Xmonad: Spawnon Workspace That Had Focus When Spawn Key Was Pressed
Finding and Listing Duplicate Words in a Plain Text File