-2

I have over-complicated this problem with if/then scripts and super simple one line commands but for some reason I keep getting stumped.

I am trying to create a new directory a-e and place the files a,b,c,d,e inside of it. For some reason it will create the directory just fine but places the files inside of the ps directory instead of the new directory.

#!/bin/bash
    
mkdir /home/adminuser/ps/a-e && touch /home/adminuser/ps/a-e {a..e}  
4
  • You've tagged this as being wanted for Ubuntu Touch, ie. a phone or tablet device using the PHONE OS now called Lomiri (previously called Ubuntu Touch). If you want people to see or refer to the link you provided in your title; it needs to be in your actual question text (any click on the title will only open this page! and some devices/setups won't show the title when you view this page anyway; thus all details need to be in your actual question text)
    – guiverc
    May 26 at 2:46
  • What kind of title is that? May 26 at 4:12
  • 2
    touch /home/adminuser/ps/a-e {a..e} will do two things: 1) Update the modification/access/change time of the already existing directory /home/adminuser/ps/a-e and 2) create five files a, b, c, d and e in your current working directory ... ps happened to be your current working directory and that is why ... touch takes arguments separated by spaces and therefore your passed arguments are actually 6 and not 5 as you expected.
    – Raffa
    May 26 at 7:51
  • you just want a / instead of a space there: touch /home/adminuser/ps/a-e/{a..e}
    – Esther
    May 30 at 21:10

1 Answer 1

3

Looks like maybe the last forward slash is missing to connect the path of the a-e directory and the filenames to be created?

Try touch /home/adminuser/ps/a-e/{a..e} and see if that works?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.