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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:27:33+00:00 2026-06-02T10:27:33+00:00

thanks for reading & your suggestions. I’m moving files into respective directories, only some

  • 0

thanks for reading & your suggestions. I’m moving files into respective directories, only some of the files use _ and some use - (underscore and hyphen) as delimiters. Is there a way to test for the different delimiters?

E.g.:

ParentDir
    1897/
    1898/
    1994summer/
    file-1897-001.txt
    file-1897-002.txt
    file-1898-001.txt
    file-1898-002.txt
    file_1994summer_001.txt
    file_1994summer_002.txt

I’ve been processing with the following (verbose so I can understand it) shell script:

!/bin/sh
for f in *.jp2
do
base=${f%.txt}
echo "base fileName is $base"
fileName=`echo "$base" | cut -f 2 -d _`
echo "truncated fileName is $fileName"
dir=$fileName
echo "Directory is $dir"
mv -v "$f" "$dir"
sleep 1
done

When using the cut command, I’d like to be able to differentiate on the delimiter. Is that possible? Thanks in advance for your time & suggestions.
Cheers!

  • 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-06-02T10:27:35+00:00Added an answer on June 2, 2026 at 10:27 am
    case "${fName}" in 
        *_* ) underscore_funnyFace_processing "${fName}" ;; 
        *-* ) hyphen_funnyFace_process "${fName}" ;; 
        * ) all_other_processing "${fName}" ;; 
    esac
    

    I’m almost sure bourne shell supported case processing. Don’t have access to one to test with.

    The difference between bourne/bash/ksh/zsh would be in the shell wildcards patterns that each shell has as an extension to the basic patterns the bourne shell supported.

    I hope this helps.

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

Sidebar

Related Questions

I am reading a xml with some fields, for example: <url>http://myurl.com/noticias/redirect.html?document=xx222&usuario=44yyy&url=http%3A%2F%2Fwww.environmental-expert.com%2FresultEachPressRelease.aspx%3Fcid%3D23745%26codi%3D234441%26lr%3D1</url> <title>The world water
I am reading about 6000 text-files into memory with the following code in a
Thanks for reading my question. I saw Gizmodo & Lifehacker has this feature. Take
Thanks to reading about error handling on StackOverflow , I discovered Mz-Tools. However, I
Thanks in Advance for reading and answer this question. I got button in asp
Hello and thanks to everyone for reading my question. I've been working on a
Thanks to suggestions from a previous question , I'm busy trying out IronPython, IronRuby
Recently, I finished reading K&R with its, almost all, exercises and examples. I was
Thank you for your reading. I often find that I need to apply a
Well, I am stuck again. Two days of reading and again, found some close

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.