为人类所用。

atmark的Python项目详细描述


atmark–awk+sed适合人类。

执行以下操作:

# Rename a files in current directory (file-name -> file_name.jpg)
$ ls | @ sub - _ "mv # @.jpg" | sh

除了这个:

# Rename a files in current directory (file-name -> file_name.jpg)
$ ls | awk '{print $1 $1}' | sed s/"-"/"_"/ | awk '{print "mv", $2, $1, ".jpg"}' | sh

更深入:

$ ls | @  sub  -  _  "mv # @.jpg" | sh
          ---  |  |  ------------
           |   |  |      \_ format string (# - link on first state,
           |   |  |                        @ - link on current state (after replace))
           |   |  |
           |   |   \_ second replace param (to replace)
           |   |
           |    \_ first replace param (what replace)
           |
            \_ function name (substitute)

更多示例:

更改文件的扩展名.html>;.php

# Atmark
$ ls | @ split . head "mv # @.php"

# Awk/Sed
$ ls | awk '{printf "mv "$0; sub(/html/,"php"); print " "$0}' | sh

打印除前三列以外的所有列

# Atmark (\t means tab)
$ ls -la | @ split_ drop 3 join \t

# Awk/Sed
$ ls -la | awk '{for(i=1;i<4;i++) $i="";print}'

按名称终止进程

# Atmark
$ ps aux | @ grep sysmond$ index 2 "kill @" | sh

# Awk/Sed
$ ps aux | grep [s]ysmond | awk '{print "kill "$2}' | sh

越来越多,越来越多。

Build Statushttps://coveralls.io/repos/klen/atmark/badge.png?branch=develophttps://pypip.in/d/atmark/badge.pnghttps://badge.fury.io/py/atmark.png

文档可在https://atmark.readthedocs.org/上获得。拉动请求 通过文档增强和/或修复是非常棒的,非常受欢迎。

Requirements

  • python=2.6

Installation

应使用pip:

pip install atmark

Bash completion

atmark支持bash完成。只需将这些行添加到您的.bashrc

_atmark_complete() {
    COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \\
                COMP_CWORD=$COMP_CWORD \\
                _ATMARK_COMPLETE=complete $1 ) )
    return 0
}

complete -F _atmark_complete -o default @ @@;

您可以使用命令轻松完成此操作:

@ -bs >> ~/.bashrc

Usage

获取帮助

$ @ -h

Atmark (@) -- is a command line utility for parsing text input and generating output.

You can pipe data within a Atmark (@) statement using standard unix style pipes ("|").
Provide for Atmark function composition and let them work for you.

Example. Replace "_" with "-" in files in current dir and change the files extensions to jpg:

    $ ls | @ replace _ -  split . "mv # @.jpg"

It is mean:

    $ ls > replace($LINE, "_", "-") > split($RESULT, ".") > format($RESULT, "mv $LINE $RESULT.jpg")

You can use "@ --debug ARGS" for debug Armark commands.

===================================================================================
LIST OF THE BUILT IN FUNCTIONS


format FORMAT_STRING         -- format and print a string.

    Symbol '@' in FORMAT_STRING represents the current value in process of composition of fuctions.
    Symbol '#' in FORMAT_STRING represents the history state.
        Where   # or #0 -- first state, #<n> (#1, #2) -- state with number n

    Synonyms: You can drop `format` function name. This lines are equalent:

        $ ls | @ upper format "@.BAK"
        $ ls | @ upper "@.BAK"

capitalize/cap       -- capitalize the string.

drop N               -- drop N elements from list/string.

equal/== PATTERN     -- return None if arg is not equal to PATTERN.

filter/if            -- filter results by value has length

head/h               -- extract the first element/character of a list/string

index/ix N           -- get the N-th element/character from list/string.

join/j SEPARATOR     -- concatenate a list/string with intervening occurrences of SEPARATOR

join_/j_             -- same as join but SEPARATOR set as ' '

kill REGEXP          -- replace in a string/list REGEXP to ''.

last                 -- get last element/character of incoming list/string.

length/len           -- return length of list/string.

lower/l              -- make the string is lowercase

map FUNCTION         -- apply the following function to each element/character in list/string.

nocolor/nc           -- Remove ansi colors from string.

notequal/!= PATTERN  -- return None if arg is equal to PATTERN.

notgrep/ng REGEXP    -- filter results by REGEXP. Leave ungrepped

replace/r/sub FROM TO -- replace in a string/list FROM to TO.

reverse/rev          -- reverse list/string.

rstrip/rs/rtrim PATTERN -- return the string with trailing PATTERN removed.

grep/g REGEXP        -- filter results by REGEXP

sort                 -- sort list/string.

split/sp SEPARATOR   -- return a list of the substrings of the string splited by SEPARATOR

split_/sp_           -- same as split by splited a string by whitespace characters

strip/s/trim PATTERN -- return the string with leading and trailing PATTERN removed.

strip_/s_/trim_      -- same as strip but trims a whitespaces.

tail/t               -- extract the elements after the head of a list

take N               -- take N elements from list/string.

upper/u              -- make the string is uppercase.

Bug tracker

如果您有任何建议、错误报告或 烦恼请向问题追踪者报告 在https://github.com/klen/atmark/issues

Contributors

  • klen(基里尔·克莱诺夫)

License

根据BSD license授权。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如果在每次迭代后返回到原始状态,java是否可以安全地对正在迭代的数组进行变异?   linux java对'main'集合的未定义引用2:ld返回1退出状态   java如何在dynamodb上按多个字段进行排序(有解决方法吗)?   java错误处理servlet停止工作,我不知道原因:(   多线程如何在Java中暂停/恢复ExecutorService中的所有线程?   java为什么是我的jsoup。连接(url)无法使用某些url?   多线程理解Java多线程中的内存可见性   java sonar scanner可以在没有sonarqube服务器的情况下工作吗   如何从java中的页面获取不同的url?   java从文件中查找命令行中指定的单词   java类的“set”方法是否应该返回“void”或“boolean”?   如何使用java代码批量读取文件内容   二进制十进制(java.lang.NumberFormatException)   java如何在同一个句子中分别替换同一个单词但大小写不同?   java Spring `RestController`方法注释了`Transactional`,但“当前没有活动的事务”?   java OWL API:如何将域分配给OWLObjectProperty上的范围   java变量末尾的$有特殊意义吗?   java什么距离计算(经度、纬度)更精确?   卡片布局java GUI