简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM