Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:50+00:00 2026-05-22T20:51:50+00:00

In a bash script I get to this point read ENE CX CY CZ

  • 0

In a bash script I get to this point

read ENE CX CY CZ <<< $(head -n 1 RESULTS_${lach}tal2)
echo $ENE
SED_ARG="-e 's/-/m/g'"
read CX2 <<< $( echo ${CX} | eval sed "$SED_ARG")
read CY2 <<< $( echo ${CY} | eval sed "$SED_ARG")
read CZ2 <<< $( echo ${CZ} | eval sed "$SED_ARG")
DIREC="${CX2}_${CY2}_${CZ2}"
echo $DIREC
cd "$DIREC"

the value of variable DIREC is the name of a directory and I get things like

m25.1240_m22.1250_m5.1540

this directory does exist, and if I do directly in bash cd m25.1240_m22.1250_m5.1540 it works and I can get inside. But on the script it does not work and I get the error:

: No such file or directory: cd: m25.1240_m22.1250_m5.1540

I do not understand why the error

PS:

echo "$DIREC" | od -c

gives

0000000   m   2   5   .   1   2   4   0   _   m   2   2   .   1   2   5
0000020   0   _   m   5   .   1   5   4   0  \r  \n
0000033
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:51:50+00:00Added an answer on May 22, 2026 at 8:51 pm

    Does your RESULTS_${lach}tal2 file have windows-style line endings? Does CZ end with a carriage return? What does this show:

    echo "$DIREC" | od -c
    

    Additionally, there’s a lot of unnecessary eval’ing going on. Bash can do replacements in variable substitution:

    read ENE CX CY CZ <<< $(head -n 1 RESULTS_${lach}tal2 | sed 's/\r$//')
    DIREC="${CX/-/m}_${CY/-/m}_${CZ/-/m}"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Linux bash script: function Print() { echo $1 } Print OK This script runs
In a bash script, I want to get the cursor column in a variable.
I'm trying to get quoted parameters of a bash script to safely be received
How do I get the path of the directory in which a Bash script
Linux bash script: #!/bin/bash function Print() { echo $1 } var=* Print $var Execution
I would like to do something like this: chroot /mount-point /path/to/script $var1 $var 2
I am trying to do some process control in a script (bash). For this
I have written small bash script to try to get the last x characters
I use OS X 10.6.5, Bash. When I run this: echo $IP; echo of;
The other day I came accross this SO question : Bash script plugin for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.