Simple
Sand
Samples
プログラミング言語サンプル集
TOPへ
Hello World!(各言語のTOP)
pr ページ付け、段組
printf 書式付き表示
pushd,popd ディレクトリ変更復帰
pwd カレントディレクトリ表示
rename ファイル名を一括変更
rev テキスト左右反転
rmdir 空のディレクトリ削除
scp リモートファイルコピー
sed ストリームエディタ
seq 数列生成
sort ソート
split ファイル分割
sleep 指定時間遅延
sum チェックサム
svn バージョン管理
tac テキスト上下反転
tail テキスト末尾抽出
tar 書庫操作、圧縮、解凍
touch タイムスタンプ更新
tr 文字一括置換
unexpand スペースタブ変換
uniq ソート済テキストの重複削除
vim vimエディタ
wc 単語数行数カウント
xargs 引数作成
zip,unzip ZIP圧縮解凍

説明のないとってもシンプルなサンプルプログラム集
COBOL awk C言語 D言語 GO言語 Lua Vim
bash Perl Gauche Clojure CLISP EmacsLisp VimScript
tcsh Ruby Groovy Java C# VBScript JavaScript
Io言語 Python Erlang Scala VB.NET Excel/VBA PHP
Tcl Haskell OCaml PowerShell Windows Unix/Linux

Linuxコマンド > xargs 引数作成

1
2
3
4
5
6
7
8
9
10
xargs [-0prtx] [-E eof-str] [-e[eof-str]] [--eof[=eof-str]]
[--null] [-d delimiter] [--delimiter delimiter]
[-I replace-str] [-i[replace-str]] [--replace[=replace-str]]
[-l[max-lines]] [-L max-lines] [--max-lines[=max-lines]]
[-n max-args] [--max-args=max-args] [-s max-chars]
[--max-chars=max-chars] [-P max-procs]
[--max-procs=max-procs]
[--interactive] [--verbose] [--exit] [--no-run-if-empty]
[--arg-file=file] [--show-limits] [--version] [--help]
[command [initial-arguments]]
~$ seq 10 
1
2
3
4
5
6
7
8
9
10
~$ 

標準出力の各行をコマンドへの引数として与える

~$ seq 10 | xargs printf "[%d]\n"
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
~$ 


~$ touch `seq 20`
~$ ls
1  10  11  12  13  14  15  16  17  18  19  2  20  3  4  5  6  7  8  9
~$ find -name '1*'
./1
./10
./11
./12
./13
./14
./15
./16
./17
./18
./19

findで見つけたファイルを削除する

~$ find -name '1*' | xargs rm
~$ ls
2  20  3  4  5  6  7  8  9
~$ 

指定ファイル以外を全部消す

~$ ls -I 20 | xargs rm
~$ ls
20
~$