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 written a KornShell (ksh) script that sets an array the following way:
I am running the following script: #!/bin/ksh ./clear_old ./rooms_xls.pl 2/23/09 cd doors ./doors_xls.pl 2/23/09
why while loop is running only once in this following script? #!/bin/ksh awk '
How do I format a date in a KornShell (ksh) script to DD-MON-YYYY? I
at the moment I'm writing a simple script in ksh who should take some
I have found the following script causes a segmentation fault and core in KornShell
when I run the following script.pl script with no arguments: ./script.pl I do not
I have the following code in KornShell (ksh): FAILURE=1 SUCCESS=0 isNumeric(){ if [ -n
I've written a simple KShell script to kick off a background task #/bin/ksh #startMonitoring
How do I transfer multiple files through SFTP using KSH unix script. I am

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.