티스토리 뷰

linux

sed 활용

fendys 2024. 4. 5. 20:36
반응형
  • sed command를 통해서 아래 포함할문구1 또는 포함할문구2 가 있는 라인은 삭제 하고 /data/result/filename명으로 저장한다.
#!/bin/bash
for file in ls *
do
    if [ -f $file ]
    then
        tmpfile="$file"
        mkdir -p /data/result
        wc -l $file >> /data/result/result.log
        sed -e '/{포함할문구1}\|{포함할문구2}/d' $file > /data/result/$tmpfile
        wc -l /data/result/$file >> /data/result/result.log
    fi
done

 

  • sed command를 통해서 아래 {team\\\":{\\\"number\\\":\\\"[0-9]\{16\}} 을 {team\\\":{\\\"number\\\":\\\"9999999999999999} 로 치환하고 /data/result/filename명으로 저장한다.
#!/bin/bash
for file in ls *
do
    if [ -f $file ]
    then
        tmpfile="$file"
        mkdir -p /data/result
        sed -e 's/team\\\\\\":{\\\\\\"number\\\\\\":\\\\\\"[0-9]\{16\}/team\\\\\\":{\\\\\\"number\\\\\\":\\\\\\"9999999999999999/g'  $file > /data/result/$tmpfile
    fi
done

 

반응형

'linux' 카테고리의 다른 글

grub2 설정 변경  (0) 2023.11.30
linux 유저 생성 스크립트  (0) 2023.11.01
linux bash user 90 day no login chshell nologin!  (0) 2023.11.01
linux 90 days no login users change nologin mode! bash scripts  (0) 2023.10.21
logstash pipline output  (0) 2023.06.14