Sponsored Content
Top Forums Shell Programming and Scripting Python - glob () - How to grep same files with different extension files Post 302896751 by Klashxx on Wednesday 9th of April 2014 06:05:02 AM
Old 04-09-2014
First: use code tags por your sample code.

This is the correct way for your needs:
Code:
import glob
text = 'abc*'
same_name_files = glob.glob(text)

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get files with a specific extension

Hi All, How do I get only the files with the .csv extension. I have a shell script something like below: #!/usr/bin/ #Directory to scan for files SCANDIR="/cmb/data/exstream/scriptslogs/"; LOGFILE="/cmb/data/exstream/scriptslogs/test.log"; cd $SCANDIR for FILE in * ; do FILENAME=$FILE... (9 Replies)
Discussion started by: janavenki
9 Replies

2. HP-UX

Files without extension

I am brand new to hp unix systems. I see some files without extension on this system. If I type name of the file it shows me so many detail but does not take me back to command prompt. What are these files and how do I come back to command prompt? Please help (1 Reply)
Discussion started by: rajahindustani
1 Replies

3. Shell Programming and Scripting

gzip files with extension

Hi, I have 1000 of files in a folder with the file extension as .csv In this some of the files are already zipped and its looks like filename.csv.gz Now i need to zip all the files in the folder to free some disk space. When i give gzip *.csv It prompts me to overwrite filename.csv.gz... (5 Replies)
Discussion started by: nokiak810
5 Replies

4. UNIX for Dummies Questions & Answers

How to list files with no extension together with *.prog files?

Hi, I know that to list files with no extension, we can use.. ls -1 | grep -v "\." And to list .prog files, we can use.. ls -1 *.prog or ls -1 | grep '.prog$' (4 Replies)
Discussion started by: adshocker
4 Replies

5. Shell Programming and Scripting

glob not matching all files in perl

I encountered a weird issue with globbing in perl not returning all files, while I was testing out a script for recursive dir-processing on my Synology NAS. Basically it didn't show (/match?) all the files in a specific directory. If I move the file to a different directory or even rename it, it... (2 Replies)
Discussion started by: odyssey
2 Replies

6. Shell Programming and Scripting

Moving files extension one by one

Hi, I'm trying to do a script that move .Gz extension (one by one) in a new repertory called old-logs and then copy what's inside old-logs to a new.log but adding a date like this (something. gz: 2012:12:09). thanks in advance for your answers. (5 Replies)
Discussion started by: Froob
5 Replies

7. Red Hat

How to rename files to files with mv extension?

currently in my directories $ ls -lrth total 32K -rw-r--r-- 1 oracle oinstall 864 Feb 25 16:01 cor_bin_gateway_cnt.sql -rw-r--r-- 1 oracle oinstall 782 Feb 25 16:01 mer_bin_gateway_cnt.sql I want to rename files with *.sql to *.mv extension, but when I execute the following $ mv... (1 Reply)
Discussion started by: jediwannabe
1 Replies

8. Shell Programming and Scripting

Replacing extension of files

hi, i am having a certain files in a folder where i need to replace the extension with similar file name for eg 1.csv 2.csv 3.csv 4.csv i need to replace the extension 1.csv 1.txt 2.csv 2.txt 3.csv 3.txt (3 Replies)
Discussion started by: rohit_shinez
3 Replies

9. Shell Programming and Scripting

Using glob() in python script in Linux

Hi I need some suggestion on glob function. I am trying to write a python program to grep some specific files in a particular directory. In the directory i have some files like below abc.log abc.pid abc.tar gadd.tar gat.log gat.tar in this directory i need to grep onlu my hostname files,... (1 Reply)
Discussion started by: kumar85shiv
1 Replies

10. 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
GLOB_MATCH(9)						       libata Core Internals						     GLOB_MATCH(9)

NAME
glob_match - match a text string against a glob-style pattern SYNOPSIS
int glob_match(const char * text, const char * pattern); ARGUMENTS
text the string to be examined pattern the glob-style pattern to be matched against DESCRIPTION
Either/both of text and pattern can be empty strings. Match text against a glob-style pattern, with wildcards and simple sets: ? matches any single character. * matches any run of characters. [xyz] matches a single character from the set: x, y, or z. [a-d] matches a single character from the range: a, b, c, or d. [a-d0-9] matches a single character from either range. The special characters ?, [, -, or *, can be matched using a set, eg. [*] Behaviour with malformed patterns is undefined, though generally reasonable. SAMPLE PATTERNS
"SD1?", "SD1[0-5]", "*R0", "SD*1?[012]*xx" This function uses one level of recursion per '*' in pattern. Since it calls _nothing_ else, and has _no_ explicit local variables, this will not cause stack problems for any reasonable use here. RETURNS
0 on match, 1 otherwise. AUTHOR
Jeff Garzik Author. COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 GLOB_MATCH(9)
All times are GMT -4. The time now is 09:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy