Sponsored Content
Full Discussion: Check file extension
Top Forums Shell Programming and Scripting Check file extension Post 302101047 by Glenn Arndt on Wednesday 27th of December 2006 09:19:39 AM
Old 12-27-2006
Using ksh built-in:
Code:
file="foo.bar.baz.quux"
echo ${file##*.}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

filename extension check - regular expression

How to compare the file name for "zip" or "ZIP" extension. I can put one more || condition to check the upper case in the below: if ]; then Is there any better way to compare using regular expressions. Thx in advance. (4 Replies)
Discussion started by: devs
4 Replies

2. Shell Programming and Scripting

How do i check whether a file has extension?

Hi, How do i check whether a file has extension? I need to code a script that will check whether a file has extension or not. Say a file Rpt200 If the file doesn't have an extenion, I need to rename the file with .txt extension. For example Rpt200 will become Rpt200.txt Please advice. ... (2 Replies)
Discussion started by: sunday8
2 Replies

3. Shell Programming and Scripting

How to check that passed parameters all have the same extension?

$ ls monkey.txt banana.csv tree.txt $ myscript monkey.txt tree.txt All extensions ARE alike. $ myscript *txt All extensions ARE alike. $ myscript monkey.txt banana.csv All extensions are NOT alike. $ myscript * All extensions are NOT alike. My brain has given up; what's the simplest... (11 Replies)
Discussion started by: cs03dmj
11 Replies

4. UNIX for Dummies Questions & Answers

About the file extension

Hi everyone, Can we know that which type of file is there without opening a file thanks in advance.... kunal patil (3 Replies)
Discussion started by: kunalpatil09
3 Replies

5. UNIX for Dummies Questions & Answers

creating separate directories according to file extension and keeping file in different directory as

unix program to which a directory name will be passed as parameter. This directory will contain files with various extensions. This script will create directories with the names of the extention of the files and then put the files in the corresponding folder. All files which do not have any... (2 Replies)
Discussion started by: Deekay.p
2 Replies

6. Shell Programming and Scripting

Getting the file extension

I have a file n06-z30-sr65-rgdt0p25-varp0.25-8x6drw-test.cmod and I want to get the extension. At the moment I have set filextension = `echo $f | awk 'BEGIN {FS="."} {print $2}'` which of course does not work as there is a point in varp0.25 (13 Replies)
Discussion started by: kristinu
13 Replies

7. Shell Programming and Scripting

Check for file with a particular extension in a particular directory

Hi, I have a directory which I am passing in my script as a parameter. Parameter name has been set to $TCH_FILE_DIRECTORY. I want to know if there's atleast 1 (or more) files in this directory with the extension '.tch'. How can I find this using ksh. (4 Replies)
Discussion started by: Bhavesh Sharma
4 Replies

8. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

9. UNIX for Dummies Questions & Answers

File Extension Missing in file-$var.csv

I'm afraid this is a silly question but I can't figure it out. I have a script like so... echo "Enter DRDL Signature Version Number" read DRDL_Number mv signature_output.csv SERVICE_OBJECTS_S-$DRDL_Number.csv The resultant filename does not contain the .csv as follows.... (3 Replies)
Discussion started by: Cludgie
3 Replies

10. Shell Programming and Scripting

Rename specific file extension in directory with match to another file in bash

I have a specific set (all ending with .bam) of downloaded files in a directory /home/cmccabe/Desktop/NGS/API/2-15-2016. What I am trying to do is use a match to $2 in name to rename the downloaded files. To make things a more involved the date of the folder is unique and in the header of name... (1 Reply)
Discussion started by: cmccabe
1 Replies
Data::Dumper::Concise(3)				User Contributed Perl Documentation				  Data::Dumper::Concise(3)

NAME
Data::Dumper::Concise - Less indentation and newlines plus sub deparsing SYNOPSIS
use Data::Dumper::Concise; warn Dumper($var); is equivalent to: use Data::Dumper; { local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 1; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Deparse = 1; local $Data::Dumper::Quotekeys = 0; local $Data::Dumper::Sortkeys = 1; warn Dumper($var); } So for the structure: { foo => "bar baz", quux => sub { "fleem" } }; Data::Dumper::Concise will give you: { foo => "bar baz", quux => sub { use warnings; use strict 'refs'; 'fleem'; } } instead of the default Data::Dumper output: $VAR1 = { 'quux' => sub { "DUMMY" }, 'foo' => 'bar baz' }; (note the tab indentation, oh joy ...) If you need to get the underlying Dumper object just call "DumperObject". Also try out "DumperF" which takes a "CodeRef" as the first argument to format the output. For example: use Data::Dumper::Concise; warn DumperF { "result: $_[0] result2: $_[1]" } $foo, $bar; Which is the same as: warn 'result: ' . Dumper($foo) . ' result2: ' . Dumper($bar); DESCRIPTION
This module always exports a single function, Dumper, which can be called with an array of values to dump those values. It exists, fundamentally, as a convenient way to reproduce a set of Dumper options that we've found ourselves using across large numbers of applications, primarily for debugging output. The principle guiding theme is "all the concision you can get while still having a useful dump and not doing anything cleverer than setting Data::Dumper options" - it's been pointed out to us that Data::Dump::Streamer can produce shorter output with less lines of code. We know. This is simpler and we've never seen it segfault. But for complex/weird structures, it generally rocks. You should use it as well, when Concise is underkill. We do. Why is deparsing on when the aim is concision? Because you often want to know what subroutine refs you have when debugging and because if you were planning to eval this back in you probably wanted to remove subrefs first and add them back in a custom way anyway. Note that this -does- force using the pure perl Dumper rather than the XS one, but I've never in my life seen Data::Dumper show up in a profile so "who cares?". BUT BUT BUT ... Yes, we know. Consider this module in the ::Tiny spirit and feel free to write a Data::Dumper::Concise::ButWithExtraTwiddlyBits if it makes you happy. Then tell us so we can add it to the see also section. SUGARY SYNTAX
This package also provides: Data::Dumper::Concise::Sugar - provides Dwarn and DwarnS convenience functions Devel::Dwarn - shorter form for Data::Dumper::Concise::Sugar SEE ALSO
We use for some purposes, and dearly love, the following alternatives: Data::Dump - prettiness oriented but not amazingly configurable Data::Dump::Streamer - brilliant. beautiful. insane. extensive. excessive. try it. JSON::XS - no, really. If it's just plain data, JSON is a great option. AUTHOR
mst - Matt S. Trout <mst@shadowcat.co.uk> CONTRIBUTORS
frew - Arthur Axel "fREW" Schmidt <frioux@gmail.com> COPYRIGHT
Copyright (c) 2010 the Data::Dumper::Concise "AUTHOR" and "CONTRIBUTORS" as listed above. LICENSE
This library is free software and may be distributed under the same terms as perl itself. perl v5.18.2 2013-12-31 Data::Dumper::Concise(3)
All times are GMT -4. The time now is 10:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy