- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk doubt
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 07:39 AM
04-29-2002 07:39 AM
how can I get the file name without extention from the list of files?
ex. I have the name: 24145123.sc
that 24145123 is the string I need.
thanx.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 07:44 AM
04-29-2002 07:44 AM
Re: awk doubt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 07:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 07:47 AM
04-29-2002 07:47 AM
Re: awk doubt
Just my two cents.
-Sukant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 07:47 AM
04-29-2002 07:47 AM
Re: awk doubt
ls |grep *.sc |cut -d"." -f1
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 07:49 AM
04-29-2002 07:49 AM
Re: awk doubt
there is a simpler way if that is waht you are trying to do
echo 24145123.sc | cut -c 1-8 will give you the file name w/o the externsion.
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 07:54 AM
04-29-2002 07:54 AM
Re: awk doubt
Be carefull with cut -c. Cut -c does not have the ability to do padding like awk can. I think awk is your best chose for what you are trying to do.
-Yates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 08:01 AM
04-29-2002 08:01 AM
Re: awk doubt
withext="12332234.sc"
without=${withext%.*}
echo $without
12332234
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 08:08 AM
04-29-2002 08:08 AM
Re: awk doubt
Let's get a little weird...
echo sc.sc.sckjs.scsc.scs.sc | awk '{FS="\.sc$"} {print $1}'
This allows for multiple "dots" in the filename as well as multiple occurances or ".sc". Not to mention that the "$" anchors
".sc" to the end of the filename and the "\" keeps the "." from being expanded as a wildcard.
Rodney's tip works well! It's much simpler than this.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 08:28 AM
04-29-2002 08:28 AM
Re: awk doubt
and an alternative to awk
echo 24145123.sc | sed -e 's/.sc//g'
cheers
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 08:39 AM
04-29-2002 08:39 AM
Re: awk doubt
I can't resist...Rodney's solution is the fastest, since the shell is doing the work rather than spawning another process.
Another 'awk' variation, which would be useful if you had multiple fields (columns) each with "."s might look like this:
# echo "abc.123 def.456 ghi.789"|awk '{split($3,a,".");print a[1]}'
In the above example, "ghi" (the first part of the third field) would be returned.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2002 01:53 AM
04-30-2002 01:53 AM
Re: awk doubt
There is a command exactly for this:
basename 24145123.sc .sc
(only works if you know the extension, ie '.sc' though)
Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2002 05:03 AM
04-30-2002 05:03 AM
Re: awk doubt
This points out how often there are other uses for UNIX commands other than the one(s) we typically use. Also the value of these forums.
N/A please.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2002 11:09 AM
04-30-2002 11:09 AM
Re: awk doubt
echo "this.that" | sed 's/\..*//'