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 3438876
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:14:27+00:00 2026-05-18T08:14:27+00:00

The following Ksh script gives me No such file or directory error message on

  • 0

The following Ksh script gives me “No such file or directory” error message on Red Hat Linux system. Does anyone has a solution?

#!/usr/bin/ksh
for f in `cat files.dat`
do
  wc $f
done

For example, files.dat has 3 lines of data and each line is a file in the current directory where the script is running from.

a.c
a.h
b.c

Note, the same for loop generated the same error message if running from command line too.

It works on Solaris/Mac box but not on Red Hat system.

Thanks.

  • 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-18T08:14:27+00:00Added an answer on May 18, 2026 at 8:14 am

    Instead of for ... cat, you should use

    while read -r f
    do
        wc "$f"
    done < files.dat
    

    And you should use $() instead of backticks when you do need to do command substitution.

    But your problem is probably that the files a.c, etc., are not there, have different names, invisible characters in their names, or the line endings in files.dat are CR/LF (DOS/Windows-style) instead of \n (LF only – Unix-style) or there are odd characters in the file otherwise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following shell script that echos output to the log and errors
I have a script that needs to use associative arrays. Being new to ksh
Following is the error I am getting when I tried 'git svn rebase': Byte
Following doesn't work. I need to add a , and an input param at
Following a specific action the user takes on my website, a number of messages
Following on from MySQL multiple Id lookups So I'm looking at other ways around
Following my previous question, DAO and Service layers (JPA/Hibernate + Spring) , I decided
Following is the URL. I want to play following URL video in my iPhone
Following is an example code test harness which emulates the problem I am experiencing.

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.