sed

bash-3.00# test=hello
bash-3.00# echo hello world | sed 's/$test/HELLO/'
hello world
bash-3.00# echo hello world | sed "s/$test/HELLO/"
HELLO world

bash-3.00# echo '$test'
$test
bash-3.00# echo $test
hello
bash-3.00# echo "$test"
hello
-----------------
bash-3.00# sed 's/root/ROOT/' a.txt
ROOT console Apr 10 15:17 (:0)
ROOT pts/3 Apr 10 15:20 (:0.0)


bash-3.00# sed 's:root:ROOT:' a.txt
ROOT console Apr 10 15:17 (:0)
ROOT pts/3 Apr 10 15:20 (:0.0)
-------------------
[user@8126ef369b1b test]$ sed 's/:/\t/g' /etc/passwd > out                                                                
[user@8126ef369b1b test]$ cat out                                                                                         
root    x       0       0       root    /root   /bin/bash                                                                 
bin     x       1       1       bin     /bin    /sbin/nologin                                                             
daemon  x       2       2       daemon  /sbin   /sbin/nologin                                                             
adm     x       3       4       adm     /var/adm        /sbin/nologin                                                     
lp      x       4       7       lp      /var/spool/lpd  /sbin/nologin                                                     
sync    x       5       0       sync    /sbin   /bin/sync                           


Comments

Popular posts from this blog

HAproxy logging

tomcat catalina coyote jasper cluster

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all