this post was submitted on 11 Aug 2024
1 points (100.0% liked)

Linux

5081 readers
32 users here now

A community for everything relating to the linux operating system

Also check out [email protected]

Original icon base courtesy of [email protected] and The GIMP

founded 1 year ago
MODERATORS
top 9 comments
sorted by: hot top controversial new old
[–] [email protected] 0 points 2 months ago* (last edited 2 months ago)

can anyone help me figure out, why the following shell script does not work:

#!/bin/bash
while IFS= read -d $'\0' -r "dir" ; do 
      dir=${dir:2};
      echo "${dir}"\#;
      cd "'""${dir}""'" ;
      ls;
      ##doing something else
     # cd  ..;
done < <(find ./  -mindepth 1 -maxdepth 1 -type d -print0)

I am running it in a location with a lots of folders containing spaces (think of it like this:

/location containing spaces# ls
'foo ba' 'baa foo ' 'tee pot'

I get errors of the following form:

script.sh: line 5: cd: 'baa foo ': No such file or directory

but when I manually enter cd 'baa foo' it works fine. Why could that be? (the echo retuns something like "foo baa #" .) It really confuses me that the cd with the exact same string works when I enter it manually. I have allready tried leaving out the quotes in the cd command and escaping the spaces using dir=$(printf %q "${dir}"); before the cd but that did not work either.

tbh I am new to shell scripts so maybe there is something obvious I overlooked.

[–] [email protected] 0 points 2 months ago (2 children)

i was wondering if there was any program akin to autohotkey for linux, i found one that does text replacement and it's fine but i really liked the stuff you could do with autohotkey, i had an entire popup menu of little tools on windows

[–] [email protected] 0 points 2 months ago (1 children)

Perhaps xdotool (assumming X11 and not wayland, there might be a fork? idk). Random self-reference trivia fact: I never used AHK, heard many great things about it and regretted a lot being on Linux by then. This was ~11 years ago. Then, some years later, at a gig I needed to type pre-formatted emails (like every 2 weeks, answering the same) and for that I used xdotool and assigned the commands as custom shortcuts under KDE :) it was one of my proudest moments towards Open Source Software.

[–] [email protected] 0 points 2 months ago* (last edited 2 months ago)

also have that lmao, yea it's useful but it doesn't come with a ui so no custom menus. ig i should just bite the bullet and learn bash to use with yad

[–] [email protected] 0 points 2 months ago (1 children)

I don't remember the name but there is one alternative that is made on Python and you can write the rules on Python.

I don't know if it works on Wayland tho.

[–] [email protected] 0 points 2 months ago

autokey-gtk probably, it's the one i already use

[–] [email protected] 0 points 2 months ago (1 children)
[–] [email protected] 0 points 2 months ago* (last edited 2 months ago) (1 children)

[/j] that is not a question. banned, blocked, ICBM en route to your position

[–] [email protected] 0 points 2 months ago