Red
Red

Reputation: 65

mkdir producing wrong folder name

I have a problem using "mkdir" in my script file.

This is my script

#!/bin/bash
mkdir "wavlist"
cat 0160.121213.084834.log 0161.121213.085943.log 0162.121214.004916.log | grep .\.wav | cut -f 1 -d ' ' > wavlist/drills01.wavlist

whenever I execute this. The directory that it will create has a name "wavlist."

Why is there a "." at the end?

The output of bash -x

+ $'\r'
Drills01Commands_Celso.sh: line 2: $'\r': command not found
+ mkdir $'wavlist\r'
+ $'\r'
Drills01Commands_Celso.sh: line 4: $'\r': command not found
+ cat logfiles/0160.121213.084834.log logfiles/0161.121213.085943.log logfiles/0162.121214.004916.log
+ grep ..wav
+ cut -f 1 -d ' '
: No such file or directoryline 5: wavlist/drills01.wavlist
+ $'\r'
Drills01Commands_Celso.sh: line 6: $'\r': command not found

Upvotes: 1

Views: 2000

Answers (1)

michas
michas

Reputation: 26515

Seems like you saved your script with windows line endings. That is why it complains about "\r".

Save with Unix line endings and try again.

The dot displayed by ls is actually the " \r" from the line ending.

Upvotes: 5

Related Questions