Commands tagged argument (8)

  • After executing a command with multiple arguments like cp ./temp/test.sh ~/prog/ifdown.sh you can paste any argument of the previous command to the console, like ls -l ALT+1+. is equivalent to ls -l ./temp/test.sh ALT+0+. stands for command itself ('ls' in this case) Simple ALT+. cycles through last arguments of previous commands.


    13
    <ALT>+<.> or <ALT>+<NUM>+<.> or <ALT>+<NUM>,<ALT>+<.>
    aikikode · 2011-03-01 17:41:08 4
  • Bash's history expansion character, "!", has many features, including "!:" for choosing a specific argument (or range of arguments) from the history. The gist is any number after !: is the number of the argument you want, with !:1 being the first argument and !:0 being the command. See the sample output for a few examples. For full details search for "^HISTORY EXPANSION" in the bash(1) man page.    Note that this version improves on the previous function in that it handles arguments that include whitespace correctly. Show Sample Output


    10
    !:n
    hackerb9 · 2013-09-15 03:41:13 7
  • if you want to move with command mv large list of files than you would get following error /bin/mv: Argument list too long alternavite with exec: find /source/directory -mindepth 1 -maxdepth 1 -name '*' -exec mv {} /target/directory \; Show Sample Output


    4
    find /source/directory -mindepth 1 -maxdepth 1 -name '*' -print0 | xargs -0 mv -t /target/directory;
    aysadk · 2020-11-17 12:30:45 285
  • A really fun vim oneliner for auto documenting your option's parsing in your script. # print the text embeded in the case that parse options from command line. # the block is matched with the marker 'CommandParse' in comment, until 'esac' extract_cmdl_options() { # use vim for parsing: # 1st grep the case block and copy in register @p + unindent in the buffer of the file itself # 2nd filter lines which start with --opt or +opt and keep comment on hte following lines until an empty line # 3rd discard changes in the buffer and quit vim -n -es -c 'g/# CommandParse/+2,/^\s\+esac/-1 d p | % d | put p | % -c 'g/^\([-+]\+[^)]\+\))/,/^\(\s\+[^- \t#]\|^$\)/-1 p' \ -c 'q!' $0 } example code:http://snipplr.com/view/25059/display-embeded-comments-for-every-opt-usefull-for-auto-documenting-your-script/ Show Sample Output


    0
    vim -n -es -c 'g/# CommandParse/+2,/^\s\+esac/-1 d p | % d | put p | %<' -c 'g/^\([-+]\+[^)]\+\))/,/^\(\s\+[^- \t#]\|^$\)/-1 p' -c 'q!' $0
    syladmin · 2009-12-19 08:32:00 5
  • If Argument $1 is supplied, assign it to variable. Otherwise continue on.


    0
    [ $1 ] && my_dir=$1
    robinsonaarond · 2011-11-30 15:02:20 3
  • This gets the Nth argument in the last line of your history file. This is useful where history is being written after each command, and you want to use arguments from the previous command in the current command, such as when doing copies/moving directories etc. I wrote this after getting irritated with having to continually type in long paths/arguments. You could also use $_ if all you want is the last argument. Show Sample Output


    0
    function garg () { tail -n 1 ${HISTFILE} | awk "{ print \$$1 }" }
    plasticphyte · 2013-09-10 04:07:46 10

  • 0
    _autoOptions() { local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "--fooOption --barOption -f -b" -- $cur) ) ;}; complete -F _autoOptions autoOptions
    totti · 2013-10-16 09:46:54 9
  • This is a alternate command I like to use instead of TOP or HTOP to see what are the processes which are taking up the most memory on a system. It shows the username, process ID, CPU usage, Memory usage, thread ID, Number of threads associated with parent process, Resident Set Size, Virtual Memory Size, start time of the process, and command arguments. Then it's sorted by memory and showing the top 10 with head. This of course can be changed to suit you needs. I have a small system which is why Firefox is taking so much resources. Show Sample Output


    0
    watch -n .8 'ps -eaLo uname,pid,pcpu,pmem,lwp,nlwp,rss,vsz,start_time,args --sort -pmem| head -10'
    ubercoo · 2016-05-11 01:05:53 11

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

force unsupported i386 commands to work on amd64
The above was done using the i386 flashplayer plugin, and was installed on a AMD64 machine running an AMD64 kernel and AMD64 programs. the resulting plugin install ultimately didn't work for swiftfox (but worked for iceweasel) without also covering it with a nspluginwrapper which took a bit of fenangaling to get to work (lots of apt-getting) but it is a nice feature to be able to trick installers that think you need i386 into running on a amd64, or at least attempting to run on amd64. Enjoy

Gets the english pronunciation of a phrase
Usage examples: say hello say "hello world" say hello+world

Generat a Random MAC address
Generate a random MAC address with capital letters

Extract tarball from internet without local saving

Check whether laptop is running on battery or cable
The original proc file doesn't exist on my system.

Install pip with Proxy
Installs pip packages defining a proxy

Track X Window events in chosen window
After executing this, click on a window you want to track X Window events in. Explaination: "xev will track events in the window with the following -id, which we get by greping window information obtained by xwininfo"

dont execute command just add it to history as a comment, handy if your command is not "complete" yet

list files recursively by size

Get the IP address
gives u each configured IP in a seperate line.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: