feat(user/rsync_tranches.sh):Add bash function for parallel rsync
[BK-2020-03.git] / user / regex-backslash.sh
... / ...
CommitLineData
1#!/usr/bin/env bash
2# Desc: Backslashes regex special characters
3# Usage: cat file.txt | regex-backslash.sh
4# Version: 0.0.1
5# Depends: sed (GNU sed) 4.8; GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
6# Ref/Attrib: [1] TIL: Reading stdin to a BASH variable https://dev.to/jeremyckahn/til-reading-stdin-to-a-bash-variable-1kln
7
8STD_IN=$(</dev/stdin);
9
10printf "%s\n" "$STD_IN" | \
11 sed \
12 -e 's/\\/\\\\/g' \
13 -e 's/\./\\./g' \
14 -e 's/\+/\\+/g' \
15 -e 's/\*/\\*/g' \
16 -e 's/\?/\\?/g' \
17 -e 's/\^/\\^/g' \
18 -e 's/\$/\\$/g' \
19 -e 's/(/\\(/g' \
20 -e 's/)/\\)/g' \
21 -e 's/\[/\\[/g' \
22 -e 's/\]/\\]/g' \
23 -e 's/{/\\{/g' \
24 -e 's/}/\\}/g' \
25 -e 's/|/\\|/g' \
26 -- -;
27
28exit 0;
29
30# Author: Steven Baltakatei Sandoval
31# License: GPLv3+