Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ sed and awk in shell usage and some examples     - grub boot error resolution examples (Linux)

- Summary Linux bond of multi-interface load balancing (Linux)

- Linux disk virtualization (Linux)

- How to choose the first programming language based on the life you want (Programming)

- Ubuntu 14.04 Nvidia graphics driver installation and settings (Linux)

- Install the latest Pinta graphics editing software on Ubuntu 14.04 (Linux)

- A step by step teach have to install multi-node cluster configuration Hadoop (Server)

- Linux module mechanism of (Programming)

- MySQL Parameter Tuning Best Practices (Database)

- I like Linux Security (Linux)

- HTTP and HTTPS request response process difference (Linux)

- Construction of Android and iOS apps use Jenkins Automation (Programming)

- Quick Install software RAID on Linux (Linux)

- Java development specifications summary (Programming)

- Linux operating system set up to effectively prevent ARP attacks (Linux)

- Tmux Getting Start (Linux)

- dmidecode command Detailed (Hardware information) (Linux)

- The Linux-based security settings Ipchains Firewall (Linux)

- Java implementation file encryption and decryption (Programming)

- Alternative methods of intrusion bundled executable file new thinking (Linux)

  sed and awk in shell usage and some examples
  Add Date : 2017-08-31      

Operation and maintenance should always do with these two tools sed and awk, but to put them to good use is no easy task, it takes a long time to accumulate, rough paper used in everyday talk about some examples.


1 How to get the string string in shell length

echo $ {# string}
2 Replace text file in one or more spaces

sed -i "s / \ + / || / g" test
NOTE: \ + means that one or more of the previous character

3 Delete the text in the file "[" and "]" two characters

sed -i -e "s / \ [// g" -e "s / \] // g" text

Each column of text 4 text separated by commas, and now you want to delete the sixth column, then the output of the other columns, each separated by a space

awk 'BEGIN {FS = ","; OFS = ""} {$ 6 = ""; print $ 0}'

CPU 5 percent output for each user occupied

top -bn 1 | awk '{if (NR> 7) print $ 0}' | awk '{sum [$ 2] + = $ 9} END {for (i in sum) printf "% .2f% s \ n", sum [i], i} '| sort -nr

6 Statistics nginx's access.log each url access number and the flow output of the previous 10

awk '{print $ 7 "\ t" $ 10}' access_2010-12-8.log | awk '{S [$ 1] + = $ 2; S1 [$ 1] + = 1} END {for (i in S) print S [ i], S1 [i], i} '| sort -rn | head -10
- to compile FFmpeg In Ubuntu (Linux)
- Ubuntu Slingscold (Linux)
- Unetbootin make use U disk loading Linux system (Linux)
- Zombie process under Linux (Linux)
- To_teach you three strategies to prevent the LAN IP address theft (Linux)
- How to install or upgrade to the Linux kernel in Ubuntu 4.2 (Linux)
- Linux shared libraries .so file name and Dynamic Link (Linux)
- Ubuntu 12.04 64-bit installation Redmine + Git + ReviewBoard (Linux)
- sudoers file parsing (Linux)
- Git common skills (Linux)
- CentOS use wget (Linux)
- Install multiple Linux distributions and Fedora 21 first experience on the same hard disk (Linux)
- Automate deployment of Docker-based Rails applications (Server)
- Linux / Unix: chroot command examples to explain (Linux)
- Ten linux version of the system (Linux)
- Linux System Administrator Network Security Experience (Linux)
- The multiplexed signal driving IO (Programming)
- How to deploy Icinga client (Server)
- Linux Basic Course: tar command description (Linux)
- CentOS install expect (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.