Enviado em 25/04/2024 - 20:53h
ola galera beleza?touch directory1/txt-files/arquivo1.txt &2>&1 [1] 36405
touch directory1/txt-files/arquivo1.txt &2>&1 | awk '{print "creaed: "$2}' [1] 36490 [1]+ Done touch directory1/txt-files/arquivo1.txt
created: directory1/txt-files/arquivo1.txt, mas nao obtive sucesso
touch directory1/txt-files/arquivo1.txt &2>&1 | awk 'END{print "created: "$2}' [1] 36520 created: [1]+ Done touch directory1/txt-files/arquivo1.txt
created: directory1/txt-files/arquivo1.txt
Enviado em 25/04/2024 - 21:30h
Eu consegui resolver o seu problema usando apenas a linguagem de programação shell script, será que usando apenas essa linguagem te serve ou tem que ser com AWK?tocher() { export zero=$(if touch "${1}"; then echo "0"; else echo "1"; fi) [[ ${zero} == "0" ]] && echo "created: ${1}" || echo "Error" }
$ tocher directory1/txt-files/arquivo1.txt
Enviado em 26/04/2024 - 01:39h
tocher() { export zero=$(if touch "${1}"; then echo "0"; else echo "1"; fi) [[ ${zero} == "0" ]] && echo "created: ${1}" || echo "Error" }
$ tocher directory1/txt-files/arquivo1.txt
touch directory1/txt-files/arquivo6.txt &2>&1 | echo "sucessfuly" [3] 38736 sucessfuly [2] Done touch directory1/txt-files/arquivo6.txt
touch directory2/doc-files/arquivo1.doc &&2>&1 | echo "sucessfuly" sucessfuly
touch directory1/txt-files/arquivo1.txt ?&2>&1 | echo "sucessfuly" [1] 38848 sucessfuly
[2] 38852 sucessfuly [1] Done touch directory1/txt-files/arquivo1.txt ?
Enviado em 26/04/2024 - 14:29h
Enviado em 26/04/2024 - 16:11h
Boa tarde Dark.______________________________________________________________________ Importante: lynx --dump https://www.vivaolinux.com.br/termos-de-uso/ | sed -nr '/^[ ]+Se/,/udou.$/s/^[ ]+//p' ______________________________________________________________________ Nota de esclarecimento: O comando: ACIMA, faz parte da minha assinatura. Att.: Marcelo Oliver ______________________________________________________________________
Enviado em 26/04/2024 - 16:18h
O touch não tem opção verbose, logo não há como filtrar saída com a awk. Nesse caso tu tens 2 opções:#!/bin/sh arquivo='xxx/yyy/zzz.txt' if touch "${arquivo}"; then echo "${arquivo}: arquivo criado/atualizado com sucesso." fi
$ echo 'xxx/yyy/zzz.txt' | xargs -t -I % touch %
touch xxx/yyy/zzz.txt
Enviado em 27/04/2024 - 10:40h
Tem um problema no comando acima, porque ele não esta tratando erro, para isso é necessario um if, o comando agora esta assim, testado e funcionando:temp="$(mktemp)"; echo 'arquivo1.txt' | xargs -t -I % touch % 2>&1 | sed 's/touch/created: /' >"${temp}"; if [[ $(wc -l <"${temp}") == "1" ]]; then cat "${temp}"; else echo "Error"; fi; [[ -e "${temp}" ]] && rm "${temp}"
Enviado em 27/04/2024 - 19:18h
temp="$(mktemp)"; echo 'arquivo1.txt' | xargs -t -I % touch % 2>&1 | sed 's/touch/created: /' >"${temp}"; if [[ $(wc -l <"${temp}") == "1" ]]; then cat "${temp}"; else echo "Error"; fi; [[ -e "${temp}" ]] && rm "${temp}"
alias sfiles1='func(){ echo "${1}" | xargs -t -I % touch % 2>&1 | sed "/touch/ s/^touch/created:/"; }; func'
alias tfiles2='func(){ temp="$(mktemp)"; filename="${1}"; echo -e "${filename}" | xargs -t -I % touch % 2>&1 | sed "/touch/ s/touch/created:/" > "${temp}"; if [ "$(head "${temp}" | wc -l)" -eq 1 ]; then cat "${temp}"; else echo -e "toucher: cannot touch ${filename}"; fi; [ -e "${temp}" ] && rm -v "${temp}"; }; func'
$ ls -R .: directory1 directory2 ./directory1: txt-files ./directory1/txt-files: ./directory2: doc-files ./directory2/doc-files:
$ touch directory{1/txt-files/arquivo1.txt,2/doc-files/arquivo1.doc} $ ls -R .: directory1 directory2 ./directory1: txt-files ./directory1/txt-files: arquivo1.txt ./directory2: doc-files ./directory2/doc-files: arquivo1.doc
$ sfiles1 directory{1/txt-files/arquivo1.txt,2/doc-files/arquivo1.doc} created: directory1/txt-files/arquivo1.txt $ ls -R .: directory1 directory2 ./directory1: txt-files ./directory1/txt-files: arquivo1.txt ./directory2: doc-files ./directory2/doc-files:
$ tfiles1 directory{1/txt-files/arquivo1.txt,2/doc-files/arquivo1.doc} created: directory1/txt-files/arquivo1.txt $ ls -R .: directory1 directory2 ./directory1: txt-files ./directory1/txt-files: arquivo1.txt ./directory2: doc-files ./directory2/doc-files:
Enviado em 28/04/2024 - 00:36h
Aqui esta a correção para o comando, o que esta faltando é um "for" e uma mudança de "${1}" para "${@}".alias tfiles2='criar(){ temp="$(mktemp)"; for recebe in "${@}"; do echo "${recebe}" | xargs -t -I % touch % 2>&1 | sed "s/touch/created:/" > "${temp}"; if [[ "$(cat "${temp}" | wc -l)" == "1" ]]; then cat "${temp}"; else echo "toucher: cannot touch ${1}"; fi; done; [[ -e "${temp}" ]] && rm -v "${temp}"; }; criar'Ainda continua escrito 100% em shell.
Enviado em 28/04/2024 - 01:34h
Leia para saber sobre as variáveis especiais do shell:Como gerar qualquer emoji ou símbolo unicode a partir do seu teclado
Instalar e Configurar o Slackware Linux em 2025
Como configurar os repositórios do apt no Debian 12 em 2025
Passkeys: A Evolução da Autenticação Digital
Instalação de distro Linux em computadores, netbooks, etc, em rede com o Clonezilla
Configurando o Conky para iniciar corretamente no sistema
3 configurações básicas que podem melhorar muito a sua edição pelo editor nano
Como colorir os logs do terminal com ccze
Instalação Microsoft Edge no Linux Mint 22
Como configurar posicionamento e movimento de janelas no Lubuntu (Openbox) com atalhos de teclado
Instalar debian testing (13) "por cima" do debian 12 (0)
firefox nao guarda meus logins nos sites (0)
Erro de segmentação «Segmentation fault (core dumped)» ao retornar obj... (1)