Capture filenames with a Pattern into another file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Capture filenames with a Pattern into another file
# 8  
Old 09-28-2011
The command you were given is correct.

When you stripped out all the spaces and squashed it into one pattern, you made it wrong.
# 9  
Old 09-28-2011
Watch out for the spaces
Code:
ls any_name*.txt /anydir/* >All_File_Names.txt

# 10  
Old 09-28-2011
can u pls give me the exact command?
the filepattern is filetest_*
the directory is incoming
The file which has to be created is All_File_Names.txt

what exactly is the command?
# 11  
Old 09-28-2011
I don't understand your confusion. These are almost exactly like the patterns you've been using already, except UNIX uses / for directories instead of \.

Code:
ls incoming/filetest_* > All_File_Names.txt

# 12  
Old 09-28-2011
Code:
# ls -ld *
drwxr-xr-x 2 root root 4096 2011-09-28 20:56 d1
drwxr-xr-x 2 root root 4096 2011-09-28 20:57 d2
# ls -ld d*/f*
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d1/f11
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d1/f12
-rw-r--r-- 1 root root 0 2011-09-28 20:56 d1/f32
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d2/f21
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d2/f22
-rw-r--r-- 1 root root 0 2011-09-28 20:57 d2/f31
# ls -ld d1/*
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d1/f11
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d1/f12
-rw-r--r-- 1 root root 0 2011-09-28 20:56 d1/f32
# ls -ld d1/f*2
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d1/f12
-rw-r--r-- 1 root root 0 2011-09-28 20:56 d1/f32
# ls -ld */*
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d1/f11
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d1/f12
-rw-r--r-- 1 root root 0 2011-09-28 20:56 d1/f32
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d2/f21
-rw-r--r-- 1 root root 0 2011-09-28 20:52 d2/f22
-rw-r--r-- 1 root root 0 2011-09-28 20:57 d2/f31
#

# 13  
Old 09-28-2011
Thank you all for your prompt responses. Have a good time!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Pattern Match FileNames

I am on AIX. I need to list the contents of the directory based on a pattern and write an XML output file with file names. If a filename does NOT match the below pattern then write an OUTPUT xml file in the below xml format Pattern Starts with (.abc) and contains (def) Starts with... (4 Replies)
Discussion started by: techedipro
4 Replies

2. Shell Programming and Scripting

Big pattern file matching within another pattern file in awk or shell

Hi I need to do a patten match between files . I am new to shell scripting and have come up with this so far. It take 50 seconds to process files of 2mb size . I need to tune this code as file size will be around 50mb and need to save time. Main issue is that I need to search the pattern from... (2 Replies)
Discussion started by: nitin_daharwal
2 Replies

3. UNIX for Dummies Questions & Answers

Distinct filenames pattern

Hi All, I am working on designing the archival process for my system, where I will have to find distinct file names ( when excluded time_stamp extention ) from given directory and for each file type keep the latest and move all other older to different location ( lets say dir Back ). Below are... (2 Replies)
Discussion started by: freakabhi
2 Replies

4. Shell Programming and Scripting

How to capture a string enclose by a pattern within a file?

Hi all, My file :test.txt just like this: ........................... From: 333:123<sip:88888888888@bbbb.com To: <sip:123456@aaaaa.com ......................... I want a script to capture the string between sip: & @ Expect output: 88888888888 123456 Please help! (4 Replies)
Discussion started by: Alex Li
4 Replies

5. UNIX for Dummies Questions & Answers

Searching for a pattern from filenames stored in a file

Hi, I have got some 10 filenames stored in a file or displayed in the console as a result of some query i made.. Now I need to open each of these files and search for a pattern in these 10 files.. Can someone help me with this? Thanks, Jean (9 Replies)
Discussion started by: jeanjkj
9 Replies

6. Shell Programming and Scripting

Copying filenames into a new file

I have about 35,000 files in one directory. Here I have to write a ksh to take only the filenames of 500 files at a time and put them into a new file. Can anyone please help me. Thank you. (8 Replies)
Discussion started by: vpv0002
8 Replies

7. Shell Programming and Scripting

BASH find filenames in list that match certain "pattern."

I guess by "pattern," I mean something different from how that word is defined in the Linux world. If you take $ to mean a letter (a-z) and # to mean a number (0-9), then the pattern I'm trying to match is as follows: $$$##-####-###-###.jpg I'd like to write a script that reads in a list of files... (4 Replies)
Discussion started by: SilversleevesX
4 Replies

8. Programming

Sort the filenames containing . in file name

Hi All, I have a list of files in a directory ..which are look like: 42420031.1000 42420031.1001 42420031.396 42420031.402 42420031.403 42420031.404 42420031.405 42420031.406 42420031.407 42420031.408 42420031.409 Here when i do ls 42420031* |sort it gives the output as ... (3 Replies)
Discussion started by: sanj_eck
3 Replies

9. Shell Programming and Scripting

capture output of file and send last string thereof to new file

Hello, If I run a program from within shell, the output is displayed in the command line terminal. Is there a way I can capture that output and choose only the very last string in it to send it to a new file? Thank you (6 Replies)
Discussion started by: Lorna
6 Replies

10. UNIX for Advanced & Expert Users

pattern match in each line and capture it question

I need a clarification on one of the scripts that i have written, I new to file handling and i need help: I am trying to find a particular pattern in a file "****** PBX" in set of 5 files named: xy.cc3 xv.cc3 xx.cc3 xr.cc3 xd.cc3 in a directory. If i find the files starting with these... (16 Replies)
Discussion started by: bsandeep_80
16 Replies
Login or Register to Ask a Question