Skip to content

Commit 7554cdf

Browse files
Update README.md
1 parent 4649ad9 commit 7554cdf

File tree

1 file changed

+56
-49
lines changed

1 file changed

+56
-49
lines changed

README.md

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
\# Completed on Thu Mar 5 11:22:52 2020
4343

4444
cat /etc/rsyslog.d/40-iptables.conf
45-
:msg, regex, "iptables:" -/var/log/firewall.log \
45+
:msg, regex, "iptables:" -/var/log/firewall.log
4646
& ~
4747

4848
sudo /etc/init.d/rsyslog restart
@@ -75,96 +75,103 @@ Ejemplo fichero netplan:
7575
# Bash
7676

7777
## Ejemplo Bucle For
78-
> for i in $(ls -a); do echo "fichero ${i}"; done
78+
for i in $(ls -a); do echo "fichero ${i}"; done
7979

8080
## Ejemplo Bucle While infinito
81-
> while [ true ]; do echo "hello world\n"; sleep 3; done
81+
while [ true ]; do echo "hello world\n"; sleep 3; done
8282

8383
***
8484

8585
# Shell-script
8686

8787
# Inicio bash
8888

89-
> #!/bin/bash \
90-
> \
91-
> ECHO=$(which echo) \
92-
> CAT=$(which cat) \
93-
> NMAP=$(which nmap) \
94-
> RM=$(which rm) \
95-
> DIFF=$(which diff) \
96-
> ...
89+
#!/bin/bash
90+
91+
ECHO=$(which echo)
92+
CAT=$(which cat)
93+
NMAP=$(which nmap)
94+
RM=$(which rm)
95+
DIFF=$(which diff)
96+
...
9797

9898
# Function
9999

100-
> function Usage () { \
101-
> ${ECHO} -e "SYNTAX ERROR: ${0} [opcion1|opcion2] <nombre>\n" \
102-
> exit 1 \
103-
> } \
100+
function Usage () {
101+
${ECHO} -e "SYNTAX ERROR: ${0} [opcion1|opcion2] <nombre>\n"
102+
exit 1
103+
}
104104

105105
## if - elif - else - fi
106106

107107
Verificamos los parametros si son nulos, y si primer parametro contiene valor correcto.
108108

109-
> if [[ -z ${1} ]] || [[ -z ${2} ]] ; then \
110-
> Usage \
111-
> elif [[ "${1}" != "opcion1" ]] && [[ "${1}" != "opcion2" ]] ; then \
112-
> Usage \
113-
> else \
114-
> accion="${1}" \
115-
> nombre="${2}" \
116-
> fi
109+
if [[ -z ${1} ]] || [[ -z ${2} ]] ; then
110+
Usage
111+
elif [[ "${1}" != "opcion1" ]] && [[ "${1}" != "opcion2" ]] ; then
112+
Usage
113+
else
114+
accion="${1}"
115+
nombre="${2}"
116+
fi
117117

118118
Si fichero existe entonces lo borramos:
119119

120-
> if [[ -f "${nombreFichero}" ]] ; then \
121-
> ${RM} ${nombreFichero} \
122-
> fi
120+
if [[ -f "${nombreFichero}" ]] ; then
121+
${RM} ${nombreFichero}
122+
fi
123123

124124

125125
## Petición parámetros
126126

127-
> ${ECHO} "Introduce un nombre:" \
128-
> read -s nombre
127+
${ECHO} "Introduce un nombre:"
128+
read -s nombre
129129

130130
## Case
131131

132-
> case $opcion in \
133-
> 0) \
134-
> ${ECHO} -e "[CORRECTO];" \
135-
> ;; \
136-
> *) \
137-
> ${ECHO} -e "[INCORRECTO];" \
138-
> ;; \
139-
> esac \
132+
case $opcion in
133+
0)
134+
${ECHO} -e "[CORRECTO];"
135+
;;
136+
*)
137+
${ECHO} -e "[INCORRECTO];"
138+
;;
139+
esac
140140

141141
***
142142
# Diff
143143

144144
## Ejemplo visualización en columnas
145-
> diff -y fichero1.txt fichero2.txt
145+
146+
diff -y fichero1.txt fichero2.txt
146147

147148
## Ejemplo comparar sin diferenciar espacios en blanco ni tabuladores
148-
> diff -wEZB fichero1.txt fichero2.txt
149+
150+
diff -wEZB fichero1.txt fichero2.txt
149151

150152
## Ejemplo modo silencioso
153+
151154
Importa el resultado del commando diff result=0 EXIT OK, result=1 FAIL.
152-
> result=$(diff -q --ignore-matching-lines="ntp clock-period" fichero1.txt fichero2.txt)
155+
156+
result=$(diff -q --ignore-matching-lines="ntp clock-period" fichero1.txt fichero2.txt)
153157

154158
## Ejemplo ignorando lineas
159+
155160
Las líneas con contenido "ntp clock-period" son ignoradas.
156-
> diff --ignore-matching-lines="ntp clock-period" fichero1.txt fichero2.txt
161+
162+
diff --ignore-matching-lines="ntp clock-period" fichero1.txt fichero2.txt
157163

158164
## Comandos utilies del diff
159-
> diff \
160-
> --suppress-blank-empty suppress space or tab before empty output lines \
161-
> -y, --side-by-side output in two columns \
162-
> -w, --ignore-all-space ignore all white space \
163-
> -B, --ignore-blank-lines ignore changes where lines are all blank \
164-
> -i, --ignore-case ignore case differences in file contents \
165-
> -E, --ignore-tab-expansion ignore changes due to tab expansion \
166-
> -q, --brief report only when files differ \
167-
> --suppress-common-lines do not output common lines \
165+
166+
diff \
167+
--suppress-blank-empty suppress space or tab before empty output lines
168+
-y, --side-by-side output in two columns
169+
-w, --ignore-all-space ignore all white space
170+
-B, --ignore-blank-lines ignore changes where lines are all blank
171+
-i, --ignore-case ignore case differences in file contents
172+
-E, --ignore-tab-expansion ignore changes due to tab expansion
173+
-q, --brief report only when files differ
174+
--suppress-common-lines do not output common lines
168175

169176
***
170177

0 commit comments

Comments
 (0)