Sponsored Content
Full Discussion: search for a file extension
Top Forums Shell Programming and Scripting search for a file extension Post 302378568 by ghostdog74 on Tuesday 8th of December 2009 07:25:15 AM
Old 12-08-2009
Quote:
Originally Posted by KenJackson
Interesting. Of the four answers given, three assumed he wants to loop through the files with that extension.

But he only said he needs to check if the extension exists in the directory or not. That shouldn't require a loop.
you used ls, which is the same as "looping through the files", except that ls "abstracted" the process for you.
with the shell, if he knows what extension he is searching for.
Code:
for file in *extension
do
  echo "found $file"
done

or another way
Code:
shopt -s nullglob
a=$(echo *extension)
[ -z "$a" ] && echo "null"

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

string search in folders with particular multiple file extension

Hi, I am newbie in UNIX so please excuse for my questions. Is there a a way to search for string in files within folder and sub folder in particluar file extensions. Ex. search for ABC in folder 'A'(including it's sub folders) in html, xml files. Thanks, Ani (2 Replies)
Discussion started by: anikanch
2 Replies

2. UNIX for Advanced & Expert Users

File extension search and copy

Hi need to know if we can write a shell script to find files for a particular format;s ie both .csv and .txt in a particular folder and then copy them to a new folder on a dialy basis. Does anyone know how this can be accomplished? Thanks, Sandeep (20 Replies)
Discussion started by: bsandeep_80
20 Replies

3. Shell Programming and Scripting

Search for all the unique file extension

Greetings to All ... :b: I have one root folder containing different other folders within it. I need to get the list of all different types of file extensions residing in those folders. Could anyone help me providing some shell script? (1 Reply)
Discussion started by: riverside
1 Replies

4. Shell Programming and Scripting

Recursicely search and rename file extension

Greetings to all!!:b: I have one root folder containing several other folders inside it. This tree structure is deep. And the files are of similar extension. I need to start at the top level and recursively search and rename all the files with say .a extension to .b . This is the code to... (7 Replies)
Discussion started by: riverside
7 Replies

5. 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

6. 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

7. 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

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
XkbQueryExtension(3)						   XKB FUNCTIONS					      XkbQueryExtension(3)

NAME
XkbQueryExtension - Determines the compatibility of a library at runtime. SYNOPSIS
Bool XkbQueryExtension (Display *dpy, int *opcode_rtrn, int *event_rtrn, int *error_rtrn, int *major_in_out, int *minor_in_out); ARGUMENTS
dpy connection to the X server opcode_rtrn backfilled with the major extension opcode event_rtrn backfilled with the extension base event code error_rtrn backfilled with the extension base error code major_in_out compile time lib major version in, server major version out minor_in_out compile time lib min version in, server minor version out DESCRIPTION
Call XkbQueryExtension to check for the presence and compatibility of the extension in the server and to initialize the extension. Because of potential version mismatches, you cannot use the generic extension mechanism functions ( XQueryExtension and XInitExtension ) for check- ing for the presence of, and initializing the Xkb extension. You must call XkbQueryExtension or XkbOpenDisplay before using any other Xkb library interfaces, unless such usage is explicitly allowed in the interface description in this document. The exceptions are: XkbIgnoreExtension, XkbLibraryVersion, and a handful of audible-bell func- tions. You should not use any other Xkb functions if the extension is not present or is uninitialized. In general, calls to Xkb library functions made prior to initializing the Xkb extension cause BadAccess protocol errors. XkbQueryExtension both determines whether a compatible Xkb extension is present in the X server and initializes the extension when it is present. The XkbQueryExtension function determines whether a compatible version of the X Keyboard Extension is present in the server. If a compati- ble extension is present, XkbQueryExtension returns True; otherwise, it returns False. If a compatible version of Xkb is present, XkbQueryExtension initializes the extension. It backfills the major opcode for the keyboard extension in opcode_rtrn, the base event code in event_rtrn, the base error code in error_rtrn, and the major and minor version numbers of the extension in major_in_out and minor_in_out. The major opcode is reported in the req_major fields of some Xkb events. For a discussion of the base event code. RETURN VALUES
True The XkbQueryExtension function returns True if it determines a compatible version of the X Keyboard Extension is present in the server. False The XkbQueryExtension function returns False if it determines a compatible version of the X Keyboard Extension is not present in the server. SEE ALSO
XkbIgnoreExtension(3), XkbLibraryVersion(3), XkbOpenDisplay(3) X Version 11 libX11 1.6.0 XkbQueryExtension(3)
All times are GMT -4. The time now is 01:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy