The example I do not quite understand is:
cut -d : -f /etc/passwd | tr : \t
What does the colon :
and the two \
bars mean?
The example I do not quite understand is:
cut -d : -f /etc/passwd | tr : \t
What does the colon :
and the two \
bars mean?
As with many programming languages, when writing a String , there are strings that return a value such as:
"\a" --> Sinal sonoro
"\n" --> Quebra de linha
"\t" --> Tabulação horizontal
And in ShellScript the backslash or Arrab works the same, but in that case, any character after Arrab is passed to String .
sh ~: touch my keys # cria os arquivos my e keys
sh ~: touch my\ keys # cria o arquivo my keys
And when you put them in \
sequence, the arrab is written.
sh ~: echo escreve-ndo \ arrab
#escrevendo \ arrab
While :
, has a difference where it is used, in case cut -d :
is creating a delimiter for the information to be released.
echo "Saida: Meu texto!!!!" > saida
cut -d : -f 1 saida
#Saida
That is, it will write content up before :
.
In% w / o% w / w% represents a character to be replaced.
echo "dados:lista" | tr : \- # dados-lista
But tr
can in some cases be used to assign null value to files or to a disk.
echo "dados para o arquivo" > arquivo
:>arquivo
cat arquivo
The archive content will be empty.