Suchart.Blog –> ITupstart.com

sed

TODO…

sed – stream editor for filtering and transforming text

# man sed

NAME
sed – stream editor for filtering and transforming text

SYNOPSIS
sed [OPTION]… {script-only-if-no-other-script} [input-file]…

DESCRIPTION
Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a
pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over
the input(s), and is consequently more efficient. But it is sed’s ability to filter text in a pipeline which particularly distin-
guishes it from other types of editors.

-n, –quiet, –silent

suppress automatic printing of pattern space

-e script, –expression=script

add the script to the commands to be executed

-f script-file, –file=script-file

add the contents of script-file to the commands to be executed

-i[SUFFIX], –in-place[=SUFFIX]

edit files in place (makes backup if extension supplied)

-l N, –line-length=N

specify the desired line-wrap length for the `l’ command

–posix

disable all GNU extensions.

-r, –regexp-extended

use extended regular expressions in the script.

-s, –separate

consider files as separate rather than as a single continuous long stream.
….

.

.

address อาจจะเป็น หมายเลขบรรทัด หรือ regex

command คือ คำสั่งของ sed

ถ้าใช้หลายๆคำสั่ง จะใส่คำสั่งไว้ใน { } และ แยกแต่ละคำสั่งโดยใช้ ;

.

Examples

# sed ‘/^#/d’ /etc/squid/squid.conf

# sed ‘s/pattern/word/g’ mytextfile

#  sed “s/UUID[^ ]*/UUID=`vol_id /dev/sda6|grep ID_FS_UUID_ENC|awk -F= ‘{print $2}’`/g” /boot/grub/menu.lst

.

More Info

number #1 page in Google on ‘sed’! Sed – An Introduction and Tutorial

http://en.wikipedia.org/wiki/Sed

http://sed.sourceforge.net/sed1line.txt

ให้ความเห็น »

ยังไม่มีความเห็น

RSS feed for comments on this post. TrackBack URI

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s

สร้างเว็บไซต์หรือบล็อกฟรีที่ WordPress.com.

%d bloggers like this: