[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

C Shell script to get patterns n a filename

How would I get the following numbers from  the below file names using a C Shell script?

314
4487

Files:
bad_314k_256x144_x264_250_quicktime_64.mp4
agel_4487k_512x288_x264_384_quicktime_64

Can someone help me with the syntax to get this?
I am not sure iif C Shell has regular expression
0
wademi
Asked:
wademi
  • 2
1 Solution
 
woolmilkporcCommented:
echo "bad_314k_256x144_x264_250_quicktime_64.mp4" | awk -F"_|k" '{print $2}'
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
or:
echo "bad_314k_256x144_x264_250_quicktime_64.mp4" | cut -d"_" -f2 | cut -d"k" -f1

Open in new window

0
 
TintinCommented:
Do you have to use csh?  csh is the worst shell for scripting.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Why are you giving me all points? Is woolmilkporc's awk solution not working? If it is then please post a comment why you made this choice. Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now