What's wrong with the commands below?  $ var1="~/Music/$(date +%d%m%y)" $ echo "$var1" ~/Music/240118 $ mkdir "$var1" mkdir: cannot create directory ‘~/Music/240118’: No such file or directory   However  $ mkdir ~/Music/240118   works.  Never thought I would ask such questions after years of using bash...
36164
According to  and my own understanding, the tilde expands to the home directory:  $ echo ~ /home/braiam   Now, whenever I want the shell expansion to work, i. e. using variable names such $FOO, and do not break due unexpected characters, such spaces, etc. one should use double quotes ":  $ FOO="some string with spaces" $ BAR="echo $FOO" $ echo $BAR echo some string with spaces   Why doesn't this expansion works with the tilde?  $ echo ~/some/path /home/braiam/some/path $ echo "~/some/path" ~/some/path
72295
I am new to Linux and Ubuntu and have tried changing to folders/directories with some difficulty.  Could someone explain why the following commands failed to change to the desired target folder/directory?  sharon@sharon:~$ cd Home  bash: cd: Home: No such file or directory  sharon@sharon:~$ cd /Home  bash: cd: /Home: No such file or directory  sharon@sharon:~$ cd Documents  sharon@sharon:~/Documents$ cd Downloads  bash: cd: Downloads: No such file or directory  sharon@sharon:~/Documents$ cd /Downloads  bash: cd: /Downloads: No such file or directory  sharon@sharon:~/Documents$
80577
I am trying to create directory in bulk using mkdir through shell script below is the script  #!bin/bash mkdir /tmp/report*/testfolder*/testdoank   when i run it i got an error  -bash: ./makefolder.sh: bin/bash: bad interpreter: No such file or directory   what is wrong?
5146
I've created a bash script but when I try to execute it, I get   #!/bin/bash no such file or directory   I need to run the command: bash script.sh for it to work.  How can I fix this?
3595
Do I have to do any configuration to start brace expansion? When I run mkdir {1..10}, it just creates a dir naming {1..10}.
75442
I have a directories with .MP3 files which I'd like to change the extensions to .mp3. What's the easiest way to do this? I'm think something along the lines of:  find /RootPath -type f -iname "*.mp3" -exec mv {} sed s/.*MP3/\1.mp3/ \;    ...though I know that isn't quite right. :) The substitution isn't correct and I'm not sure how to use both a mv and a sed command with -exec in find.  Would I need a bash script for this?
108138
I'm learning about Linux, started yesterday. I have a question which I couldn't answer from my book or Google. What is the difference between  ./ and / in the shell?  I'm asking this because when I run, for example, the command ./home/yogesh/Desktop/Books, I get this error:  bash: ./home/yogesh/Desktop : No such file or directory   However, on removing the dot it gives  /home/yogesh/Desktop/Books : Is a directory   Or, if I run /Desktop, it returns   /Desktop : No such file or directory   But on adding a dot before /, I get  ./Desktop: is a directory   What is the difference between ./ and /?
25903
Many days ago, I found this useful bash alias (contents of my ~/.bash_aliases)  # aliases  # finds temporary files ending with '~' and deletes them alias rm~='find . -name '*~' -print0 | xargs -0 /bin/rm -f'   Now I tried to use rm~ after cd to some directory containing 3 files ending in ~  I got this error in terminal, and files did not get deleted  find: paths must precede expression: 1n.in~ Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]   Also when I tried rm~ from /home/me, it seems to be doing nothing. Or it might be taking a lot of time.  Please tell me why am I getting error, and how to fix it.  Thanks!
28017
I'm using this command to rename files:  for fname in *; do     mv "$fname" $(echo "$fname" | sha1sum | cut -f1 -d' ') done   But it only renames in the current directory. Let's say I have many directories, and each directory contains some other directories, and last directory tree contains files. I want to rename them with random characters.  I think find . -type f should work, and have tried it, but still did not get any working command.
76522
Why does bash &lt;command&gt; fail to run?  $ bash date /bin/date: /bin/date: cannot execute binary file  $ /bin/date Fri Mar 18 05:59:24 EDT 2016  $ bash -c date Fri Mar 18 06:00:39 EDT 2016
8187
Writing my first script so I'm sure this is a basic question, but can someone please explain to me why I can:  cd ~ cd bin cd ~/bin cd 'bin'   But not  cd '~' cd '~/bin'   I need to cd to a directory path with a space in one of the directory names, so I need the quotes (it's Windows Program Files under wine). I can get around it with two cd commands, but why can't I put ~ in quotes?  If I type cd '~' (or cd "~") I get:  bash: cd: ~: No such file or directory
71039
I have this in my script. But is returning an error. If I execute the command in the console works fine  ./script.sh[16]: mv: not found [No such file or directory]   I want move some files what starts in T353 from one folder to another. REMOTE_PATH is /tmp/ and PATH is my working directory  cd $REMOTE_PATH mv T353* $PATH #this is the line 16   If I make mv /tmp/T353* . works fine.
48737
I am writing a script which loops into recent files in a folder and executes a command...   #!/bin/bash cd /home/Downloads recent_files = ($(ls -t | head -20)) for file in "${recent_files[@]}" do     ./cmd $file done   I get the following syntax error:  line 3: syntax error near unexpected token `(' line 3: `recent_files = ($(\ls -t | head -20))'
19119
mkdir -p will create a directory; it will also make parent directories as needed.  Does a similar command exist for files, that will create a file and parent directories as needed?
66951
I have this script:  echo $HOME cd $HOME cd / cd /usr/local/src/   When I run it like this  . script.sh   I get this output:  /home/user : No such file or directory : No such file or directory : No such file or directory   If I run it normally (I added #!/bin/bash before the first line)  sh script.sh   I get this output:  : not found.sh: 2: script.sh /home/user script.sh: 3: Can't cd to /home/user script.sh: 4: Can't cd to / script.sh: 5: Can't cd to /usr/local/src/   The script was run from $HOME directory each time. If I run each command one by one from shell, it executed without problems (invoking cd $HOME from within $HOME simply didn't change directory).  What must I do to make this work?
79113
I'm trying to make a bash script that would make a series of directories  and requesting a parameter of how many directories should be created.  $&gt; ./createDir.sh 5  $&gt; ls  ex_01 ex_02 ex_03 ex_04 ex_05   I tried using mkdir ex_{01..$1} but it does not seem correct. How could I make this work (without using any loop)?
54667
I just wanted to ask whether there is any command which would work on common shells (bash, dash, kornshell)? It is supposed to check if the line variable contains any part of the path.  if [[ $line =~ "$PWD"$ ]] ;then