• waigl@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    1 year ago

    Bottom left example will leave you with a lot pictures ending on “.png.jpg”.

  • Elsie@lemmy.mlM
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago

    Remember for $() to wrap it in quotes to prevent word splitting!!!

  • eyeon@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    another useful one is <(cmd here)

    It’s like $(cmd here) but instead of returning the output of the command as a string passed into the arguments, it makes a new file descriptor for the output of the command and returns the path to it, for use in commands that want a file as an argument.

    So for example if you want to use diff to compare your local passwd file to a remote one…

    diff -u <(ssh host1 cat /etc/passwd) /etc/passwd

    Admittedly I can’t think of many things I’ve used this for outside of diff and alternatives to diff…but I’ve used it there a lot, like comparing the results of running two slightly different queries.

    • v_krishna@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I use this one for comm a lot. E.g.,

      comm -12 <(sort some_file) <(grep foo some_other_file | sort)

  • aberrate_junior_beatnik@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    The most useful bash command of all: sudo apt-get -y install zsh; chsh -s zsh; exec zsh ;)

    I kid, I kid! I actually like bash a lot. I really prefer it for scripting. Arrays are extremely useful but not specified in posix. Bash is pretty ubiquitous though.

    I’m also curious if there are any bash partisans who prefer it over zsh and for what reasons.

    • ziggurat@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I’m a serious bash scripter, I mean I do it both at work and as a hobby. And zsh arrays are better. Like you can use negative indecees and stuff. I have only written shell functions in zsh (my primary shell), and not thousands of lines of scripts like I have for bash. But if zsh had as good documentation and language servers I’d probably do many scripts in zsh instead. But I can’t say for certain, as I am not as sure about performance in some situations and stuff.

      Why don’t I use posix shell if I care about performance? Because they are only faster in very simple scripts,

    • zarkanian@sh.itjust.worksOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I actually prefer fish, but I want to learn more bash because is is ubiquitous and a lot of bash stuff also works in fish.