Can someone tell me what programming language this is?

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
linux_trojan
Level 2
Level 2
Posts: 73
Joined: Fri Apr 12, 2013 4:43 pm

Can someone tell me what programming language this is?

Post by linux_trojan »

I found this code online. It does get the job done but I dont recognize the language. It cannot be simply shell script. Any one know?

Code: Select all

find . -type f -name "*.jpg" | \
    while read -r f; do [ -e "${f%.jpg}.png" ] && echo "${f%.jpg}"; done

twerq
Level 2
Level 2
Posts: 52
Joined: Sun Jul 05, 2020 10:55 am

Re: Can someone tell me what programming language this is?

Post by twerq »

This is a shell script with Bash parameter substitutions.
You may ask what exactly makes you think it can't be a shell script.

linux_trojan
Level 2
Level 2
Posts: 73
Joined: Fri Apr 12, 2013 4:43 pm

Re: Can someone tell me what programming language this is?

Post by linux_trojan »

I do shell scripting but never anything like this. I thought loops in shell were "if" and "fi" or something?

By the way, this script gives all file names with 2 different extensions. I was looking for all same file names regardless of extension. Regardless of letter case too. Any suggestions?

twerq
Level 2
Level 2
Posts: 52
Joined: Sun Jul 05, 2020 10:55 am

Re: Can someone tell me what programming language this is?

Post by twerq »

linux_trojan wrote:
Sun Jul 05, 2020 2:07 pm
I thought loops in shell were "if" and "fi" or something?
The "if" construction allows you to specify conditions. And "for" or "while" or "until" constructions allow to set loops.
linux_trojan wrote:
Sun Jul 05, 2020 2:07 pm
I was looking for all same file names regardless of extension. Regardless of letter case too. Any suggestions?
I suppose you should try awk to list only those part of filename you interested in and convert strings to lowercase. Then pipe to sort and uniq -d to show only duplicates.

User avatar
zshlover
Level 1
Level 1
Posts: 21
Joined: Sun Jul 05, 2020 8:34 am

Re: Can someone tell me what programming language this is?

Post by zshlover »

linux_trojan wrote:
Sun Jul 05, 2020 1:46 pm
I found this code online. It does get the job done but I dont recognize the language. It cannot be simply shell script. Any one know?

Code: Select all

find . -type f -name "*.jpg" | \
    while read -r f; do [ -e "${f%.jpg}.png" ] && echo "${f%.jpg}"; done
Looks like a bash script, the top line is a bash command for sure and I don't see anything about it that's not bash
Learn Python: pythonspot.com, pyqt

linux_trojan
Level 2
Level 2
Posts: 73
Joined: Fri Apr 12, 2013 4:43 pm

Re: Can someone tell me what programming language this is?

Post by linux_trojan »

looks like a good start would be this

Code: Select all

ls  | tr '[A-Z]' '[a-z]'
but how to find duplicates in basename is where I get stuck

Post Reply

Return to “Software & Applications”