Linux deleted files with spaces - linux

I have files whose name has spaces in linux and want to delete (or rename) from the command line. I've looked at several sites and say that we should put \ before the space, put '', put " " ... but none works for me. It is as if split in two by name where space. What I can do? Is it something in my settings linux console? They also say that there are many files folder, and are not mine, that is, I just want to do it for my family, not for every wallet. I put an example of what you say: ((((No existe fichero o directorio means not exists file or directory))))
->ls -lrt SINCERHOG\ 150626*
-rw-rw-r-- 1 s10283 dessiis 167 jun 26 09:25 SINCERHOG 150626092551.xls
-rw-rw-r-- 1 s10283 dessiis 0 jun 26 09:35 SINCERHOG 150626093540.xls
-rw-rw-r-- 1 s10283 dessiis 2306 jun 26 09:59 SINCERHOG 150626095953.xls
-rw-rw-r-- 1 s10283 dessiis 2306 jun 26 10:12 SINCERHOG 150626101237.xls
->rm SINCERHOG\ *
ls: no se puede acceder a SINCERHOG: No existe el fichero o el directorio
ls: no se puede acceder a 150626092551.xls: No existe el fichero o el directorio
ls: no se puede acceder a SINCERHOG: No existe el fichero o el directorio
ls: no se puede acceder a 150626093540.xls: No existe el fichero o el directorio
ls: no se puede acceder a SINCERHOG: No existe el fichero o el directorio
ls: no se puede acceder a 150626095953.xls: No existe el fichero o el directorio
ls: no se puede acceder a SINCERHOG: No existe el fichero o el directorio
ls: no se puede acceder a 150626101237.xls: No existe el fichero o el directorio

Depending on your shell, when you invoke rm SINCER* the star (*) in SINCER* makes your shell think SINCER* is a pattern and thus file name expansion kicks in. Thus replacing the pattern with the (space separated) list of filenames resulting in the command
rm SINCERHOG 150626092551.xls SINCERHOG 150626093540.xls
But what you want is
rm "SINCERHOG 150626092551.xls" "SINCERHOG 150626093540.xls"
You could also try
rm SINCERHOG\ *

I can't read your example clearly. But if there are spaces in file name put the file name in double quotes as shown below while passing to the command
If your file name is as follows
> ls *
my file name.txt
> rm "my file name.txt"

Related

NSIS not deleting files when uninstalling

I am having issues deleting files and folders. 3 days to solve this. Today i spend 6 hours and still not find the solution.
I am trying to make a simple installer/uninstaller with NSIS without using any variables, macros or complicated stuffs. My uninstaller is only able to delete the desktop shortcuts.
Solutions i tried:
searched stackoverflow for posts
tried with /REBOOTOK , delete, RmDir.
i checkd 5 times the paths on my PC (windows 10) and i think the
paths are correct.
this is my nsi script:
# Nombre del instalador. Aparece en la barra superior al lanzar el instalador.
Name "Cliente de Correo - Stephane"
# El nombre del instalador
OutFile "ClienteCorreoStephane.exe"
# Configuramos la ruta por defecto donde se instala. Se puede usar $DESKTOP para
#el escritorio
InstallDir $PROGRAMFILES\ClienteCorreoStephane
# Pedimos permisos para Windows. se puede usar "user" pero
#lo normal es usar "admin" para tener todos los permisos
RequestExecutionLevel admin
# Pantallas que hay que mostrar del instalador
# te saca una ventana preguntando en que directorio quieres instalar
# Si pones páginas, hay que poner esas 2 como mínimo. Existen más paginas.
Page directory
Page instfiles
#Cambiar el idioma
!include "MUI.nsh"
!insertmacro MUI_LANGUAGE "Spanish"
#Seccion principal
Section
# muestra una ventanita con un texto y un botón que pone "Hola Mundo" y
# un botón de "ok". El instalador no continúa hasta que pulses el botón.
messageBox MB_OK "Gracias por instalar el cliente de correos de Stephane"
# Establecemos la ruta de instalacion al directorio de instalacion
SetOutPath $INSTDIR\files
# Creamos el desinstalador
writeUninstaller "$INSTDIR\files\uninstall.exe"
# anadimos a nuestro paquete instalador los siguientes archivos
File /r ".\clienteCorreoDefinitivo_jar\*" #aqui anade todo mi proyecto
File /r "..\..\ayuda" #anade la carpeta ayuda que esta fuera del src
File /r "..\..\informes" #anade la carpeta informes que esta fuera del src
File /r "..\..\recursos" #anade la carpeta informes que esta fuera del src
# anadiremos nuestro JavaFX y JRE. Para eso cambiaremos el setoutpath. Recordar cambiar
# el nombre de las carpetas del setoutpath.
# aquí anadimos nuestro javaFX
SetOutPath $INSTDIR\files\javafx13 #Este nos crea una carpeta javafx13 y nos mete todo lo siguiente dentro
File /r "C:\Program Files\Java\javafx13\*"
# aquí anadimos nuestr JRE
SetOutPath $INSTDIR\files\java-runtime #Este nos crea una carpeta java-runtime y nos mete todo lo siguiente dentro
File /r "C:\Program Files\Java\jdk-13\bin\java-runtime\*"
#Añadimos información para que salga en el menú de desinstalar de Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ClienteCorreosStephane" \
"DisplayName" "ClienteCorreoStephane"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ClienteCorreosStephane" \
"Publisher" "Stephane - Desarrollo Interfaces"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ClienteCorreosStephane" \
"UninstallString" "$\"$INSTDIR\uninstall.exe$\""
# Creamos un acceso directo apuntando al desinstalador
createShortCut "$SMPROGRAMS\Desinstalar.lnk" "$INSTDIR\files\uninstall.exe"
createShortCut "$DESKTOP\Desinstalar.lnk" "$INSTDIR\files\uninstall.exe"
createShortCut "$DESKTOP\ClienteCorreoStephane.lnk" "$INSTDIR\files\java-runtime\bin\java.exe --module-path ..\..\javafx13\lib --add-modules javafx.controls,javafx.fxml,javafx.graphics,javafx.web,javafx.base --add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED -jar ..\..\clienteCorreoDefinitivo.jar" "$INSTDIR\files\recursos\mierda_icon.ico"
SetOutPath $INSTDIR
# Fin de la seccion
SectionEnd
# seccion del desintalador. Siempre se llamará uninstall
section "uninstall"
# borramos el desintalador primero. No pasa nada, seguirá funcionando
# aunque se disinstale a si mismo.
#delete "$INSTDIR\files\uninstall.exe"
# borramos el directorio files
#RmDir /r /REBOOTOK "$INSTDIR\files"
RmDir /r "$INSTDIR\files"
# borramos el directorio general. si quedan archivos dentro, no lo borrará
RmDir /REBOOTOK "$INSTDIR"
# Borramos la entrada del registro
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ClienteCorreosStephane"
# borramos el acceso directo del menu de inicio
delete "$SMPROGRAMS\Desinstalar.lnk"
delete "$DESKTOP\Desinstalar.lnk"
delete "$DESKTOP\ClienteCorreoStephane.lnk"
# fin de la seccion del desinstalador
sectionEnd
I also had issues loading my jar file with the desktop shortcut. How do I solve this too?
$Instdir in the uninstaller is the folder the uninstall .exe file is in, not the value it had in the installer.

Problems with a splitting text script

I want to split one big text document (.txt) into multiple ones. The text document is a bunch of debates in the Spanish parliament. The text is divided into policy initiatives (I'm not sure if that is idiomatic) and I want to split it into a document per initiative. The funny thing is that each initiative has its own title in the next form:
- DEL GRUPO PARLAMENTARIO CATALÁN (CONVERGÈNCIA I UNIÓ), REGULADORA DE LOS HORARIOS COMERCIALES. (Número de expediente 122/000004.)
- DEL DIPUTADO DON MARIANO RAJOY BREY, DEL GRUPO PARLAMENTARIO POPULAR EN EL CONGRESO, QUE FORMULA AL SEÑOR PRESIDENTE DEL GOBIERNO: ¿CÓMO VALORA USTED LOS PRIMEROS DÍAS DE SU GOBIERNO? (Número de expediente 180/000021.)
As you can see, every title is in upper case, it starts with a minus and ends with "XXX/XXXXXX.)" (where X is a digit), a dot and a close parenthesis. Every title is different from each other. I have though making some RegEx to capture those characteristics in order to have a delimiter element between those debate.
The ideal would be to select the title and the debate below it until another title appears and make a new document with that, so in the end I can have in a single document the policy initiative with its title and its own debate. Thanks to this community I've got a functional script:
awk '/^-.+[0-9]{3}\/[0-9]{6}\.\)$/ {
if (p) close (p)
p = sprintf("split%05i.txt", ++i) }
{ if (p) print > "p" }' inputfile.txt
But when I run it (with Cygwin in W10) nothing happens. I thought it was due to a Windows configuration problem or something like that, but I just tried in a Ubuntu VM and same happens, i.e., nothing happens:
$ ls -l
total 228
-rw-rw-r-- 1 ubuntu ubuntu 219166 Jan 30 11:28 tryme.txt
-rwxr-xr-x 1 ubuntu ubuntu 8259 Jan 30 11:24 ubiquity.desktop
$ awk '/^-.+[0-9]{3}\/[0-9]{6}\.\)$/ {
if (p) close (p)
p = sprintf("split%05i.txt", ++i) }
{ if (p) print > "p" }' tryme.txt
$ ls -l
total 228
-rw-rw-r-- 1 ubuntu ubuntu 219166 Jan 30 11:28 tryme.txt
-rwxr-xr-x 1 ubuntu ubuntu 8259 Jan 30 11:24 ubiquity.desktop
Any idea about what is happening here? Thank you very much.

wget cant find .listing?

I want do download a whole directory from a FileZilla FTP server.
I use
wget -r --user=XXXX --password='XXXX' ftp://XXXXXX.org:XX/Fertig/XXXXXX/
the error says:
--2018-12-16 21:19:55-- ftp://XXX.org:XX/XXX/
=> »XXXXX.org:XXXX/XXX/.listing«
Auflösen des Hostnamens »XXXX.org (XXXX.org)« … XXXXXXXXX
Verbindungsaufbau zu XXX.org (XXX.org)|XXXXX|:XXX … verbunden.
Anmelden als XXX … Angemeldet!
==> SYST ... fertig. ==> PWD ... fertig.
==> TYPE I ... fertig. ==> CWD (1) /XXX ... fertig.
==> PASV ... fertig. ==> LIST ... fertig.
XXXX.org:XXX/XXX: Datei oder Verzeichnis nicht gefundenXXXX.org:XX/XXXX/.listing: Datei oder Verzeichnis nicht gefunden
when i want to download a single file, it works, but only a recursive directory fails...
chmod 777 /media/usbdisk... now it works.
acess were denided.

What does "RUNNINGAS=`/usr/bin/id -un`" do?

What does "RUNNINGAS=/usr/bin/id -un" do?
It sets the shell variable RUNNINGAS equal to the output of the command /usr/bin/id -un. On most systems, this would be your username. Note that since, as far as we can tell here, RUNNINGAS has not been exported, the value of the variable would not be available to subshells started from this shell.
You can use man to get information on the id command (man id). Most other commands also have manpages, which are a good resource for learning what the commands are for and how to use them and their various options.
Just check the help ;)
❯ id --help [16:52:24]
Utilisation : id [OPTION]... [UTILIS]
Afficher les informations d'utilisateur et de groupe de l’UTILISateur indiqué,
ou pour l'utilisateur actuel quand UTILIS est omis.
-a ignorée, pour compatibilité avec les autres versions
-Z, --context n'afficher que le contexte de sécurité du processus
-g, --group n'afficher que le GID effectif
-G, --groups afficher tous les GID
-n, --name afficher le nom au lieu du numéro, pour -ugG
-r, --real afficher l'identifiant réel au lieu de l'effectif, avec -ugG
-u, --user n'afficher que l'UID effectif
-z, --zero délimiter la sortie avec des caractères NULL au lieu de blancs ;
impossible avec le format par défaut
--help afficher l'aide et quitter
--version afficher des informations de version et quitter
Sans aucune OPTION, afficher des informations utiles d'identification.
Aide en ligne de GNU coreutils : <http://www.gnu.org/software/coreutils/>
Signalez les problèmes de traduction de « id » à : <traduc#traduc.org>
Full documentation at: <http://www.gnu.org/software/coreutils/id>
or available locally via: info '(coreutils) id invocation'
Every user has :
a username
a user ID
UID = 0 for root
UID >= 1000 for real users usually
a group ID
a list of groups and their IDs : sudo, users, disk, lock, uucp,…
Here :
id shows user info.
-u only shows info for the current user
-n does not show the UID (user ID)
So finally you got… The username !
The reverse quotes `` allow to set the variable RUNNINGAS to what the command returns.

Bash Script for find a Script in a path and launch that another script

Look , i have this script , its for find , a Script inside a "path" , and launch the another script called ".Iniciar"
#!/bin/sh
# La Funcion de este Script es encontrar el directorio
# Real donde se encuentra el programa
# La Version Original es de :
# 17 de Febrero del 2000 - Sam Lantinga, Loki Entertainment Software
# Esta Version Ha sido Traducida por
# Inukaze De Venezuela
# Sitio : http://inukaze.wordpress.com
Encontrar_Ruta()
{
ruta_completa="`echo $1 | grep /`"
if [ "$ruta_completa" = "" ]; then
oIFS="$IFS"
IFS=:
for path in $PATH
do if [ -x "$path/$1" ]; then
if [ "$path" = "" ]; then
path="."
fi
ruta_completa="$path/$1"
break
fi
done
IFS="$oIFS"
fi
if [ "$ruta_completa" = "" ]; then
ruta_completa="$1"
fi
if [ -L "$ruta_completa" ]; then
ruta_completa=`ls -l "$ruta_completa" |sed -e 's/.* -> //' |sed -e 's/\*//'`
fi
dirname $ruta_completa
}
if [ "${RUTA_DEL_SOFTWARE}" = "" ]; then
RUTA_DEL_SOFTWARE="`Encontrar_Ruta $0`"
fi
LD_LIBRARY_PATH=.:${RUTA_DEL_SOFTWARE}:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
if [ -x "${RUTA_DEL_SOFTWARE}/.Iniciar" ]
then
cd "${RUTA_DEL_SOFTWARE}/"
exec "./.Iniciar" $*
fi
echo "No Puedo ejecutar este Software. Esta bien escrito el Script de Inicio?"
exit 1
Ok , the thing its this works with path without spaces , well , im trying to run from
path "/media/Compartido/Juegos/Emuladores & Roms/MS-D.O.S/Aladdin"
for example when my terminal is in the folder "Desktop"
$ cd $HOME/Desktop
$ sh "/media/Compartido/Juegos/Emuladores & Roms/MS-D.O.S/Aladdin"/Iniciar
No Puedo ejecutar este Software. Esta bien escrito el Script de Inicio?
I can't launch it
But if i copy the folder to "/media/Shared/Games/MS-D.O.S/Aladdin"
[ inukaze | 23-09-2014 | 08:55 pm ]
[Desktop]$ sh "/media/Shared/Games/MS-D.O.S/Aladdin"/Iniciar
Encontrado el Archivo de Configuracion para : Aladdin
DOSBox version 0.74
Copyright 2002-2010 DOSBox Team, published under GNU GPL.
---
CONFIG:Loading primary settings from config file Aladdin.conf
MIXER:Got different values from SDL: freq 22050, blocksize 256
ALSA:Can't subscribe to MIDI port (65:0) nor (17:0)
MIDI:Opened device:none
Two or more joysticks reported, initializing with 2axis
Using joystick USB Gamepad with 2 axes, 10 buttons and 0 hat(s)
Using joystick Xbox Gamepad (userspace driver) with 6 axes, 11 buttons and 1 hat(s)
and trying with "zsh" from original location
[ inukaze | 23-09-2014 | 08:58 pm ]
[Desktop]$ zsh "/media/Compartido/Juegos/Emuladores & Roms/MS-D.O.S/Aladdin"/Iniciar
Encontrado el Archivo de Configuracion para : Aladdin
DOSBox version 0.74
Copyright 2002-2010 DOSBox Team, published under GNU GPL.
---
CONFIG:Loading primary settings from config file Aladdin.conf
MIXER:Got different values from SDL: freq 22050, blocksize 256
ALSA:Can't subscribe to MIDI port (65:0) nor (17:0)
MIDI:Opened device:none
Two or more joysticks reported, initializing with 2axis
Using joystick USB Gamepad with 2 axes, 10 buttons and 0 hat(s)
Using joystick Xbox Gamepad (userspace driver) with 6 axes, 11 buttons and 1 hat(s)
this works too , but i wanna ran from bash / sh
Thank you for any help.
If paths with spaces cause problems that always means you haven't used enough quoting.
Specifically you are using variables that can contain spaces without "quoting" them.
For example in the following line.
RUTA_DEL_SOFTWARE="`Encontrar_Ruta $0`"
You don't quote $0. So when you run sh "/media/Compartido/Juegos/Emuladores & Roms/MS-D.O.S/Aladdin"/Iniciar despite quoting the path as the argument there when you use that path (as $0) in the line above what the shell sees is:
RUTA_DEL_SOFTWARE="`Encontrar_Ruta '/media/Compartido/Juegos/Emuladores' '&' 'Roms/MS-D.O.S/Aladdin/Iniciar'`"
which then doesn't set $1 correctly in your function.
So to sum up: Use more quotes.

Resources