Sponsored Content
Top Forums Shell Programming and Scripting Searching for file names in a directory while ignoring certain file names Post 302379701 by 2reperry on Friday 11th of December 2009 03:09:59 PM
Old 12-11-2009
Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question

Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain extensions. For example :

Files in directory
----------------
testfile1.txt
testfile2.txt
testfile3.txt
testfile4.txt
testfile1.exe
testfile2.exe
testfile3.exe
testfile4.exe

I have a find command like :

find . -name '*' -print > filelist.lst

This would obviously give me all of the file names listed above in the file called filelist.lst.

However, what command syntax would I use if I wanted to ignore *.exe files. So, in the end this find command should generate a file called filelist.lst which should contain only the names of the files that end in .txt.

I tried the -not command but that is not valid in my version of Sun Solaris. (i.e. find . -name "*' -not \( -name "*.exe" \) -print > filelist.lst )

---------- Post updated at 03:09 PM ---------- Previous update was at 02:57 PM ----------

Disregard. I finally found the answer.

find . -name '*' ! -name '*.exe' -print > filelist.lst
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Change All File Names in a Directory

Hi, If I have a directory full of say 100 random files, and I would like to organize them, for example: FILE001, FILE002, FILE003, FILE004, etc. How would I do this from Terminal, instead of manually changing each file? I'm using Mac OS X, if that makes a difference. Thank you in advance... (8 Replies)
Discussion started by: andou
8 Replies

2. AIX

find for specific content in file in the directory and list only file names

Hi, I am trying to find the content of file using grep and find command and list only the file names but i am getting entire file list of files in the directory find . -exec grep "test" {} \; -ls Can anyone of you correct this (2 Replies)
Discussion started by: madhu_Jagarapu
2 Replies

3. UNIX for Dummies Questions & Answers

How can I sort the file names in the directory

Hi , I have a list of files in the directory I want to sort based on the file name. But in the middle of filename contains the number based on that I need to sort.Could you suggest me on the same? Example filenames: /user1$ls RS.DEV.ISV.F1.RS.REFDATA.DATA... (1 Reply)
Discussion started by: praveen.thumati
1 Replies

4. Shell Programming and Scripting

How to read file names in the directory?

I am having n files in a directory i want to read all the file names from the script file .It is better if any one provide a sample script. Elaborating the scenario: i am having n number of sql files in a directory i am running all the sql files from a single script. sqlplus... (4 Replies)
Discussion started by: dineshmurs
4 Replies

5. UNIX for Dummies Questions & Answers

Searching File Names

I am interested in writing a really simple alias to search for duplicates in file names in a given directory. As an example, the file names follow a convention like: TGIFRIDAY_55566_RESTAURANT TGIFRIDAY_98744_RESTAURANT TGIFRIDAY_67778_RESTAURANT TGIFRIDAY_55566_RESTAURANT These are all... (8 Replies)
Discussion started by: Tennesseej
8 Replies

6. Shell Programming and Scripting

Grepping file names, comparing them to a directory of files, and moving them into a new directory

got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies

7. Shell Programming and Scripting

Searching for file names with variables

Hello everyone We have a problem about searching and copying files with variables. we have variables like $year $jday $date and we want to search the files whose name contain these variables. we tried *$year*$jday*$date or with ? instead of * thank you everyone!!! (4 Replies)
Discussion started by: miriammiriam
4 Replies

8. Shell Programming and Scripting

Compare file names on directory

Dears, Would you please help on following bash script: I want to get the most recent file named alfaYYYYMMDD.gz in one directory: for example: in directory /tmp/ ls -ltr alfa20130715.gz holding.gz alfa20130705.gz sart.txt merge.txt.gz alfa20130802.gz my result shoud be... (1 Reply)
Discussion started by: maxsub
1 Replies

9. Shell Programming and Scripting

Exclude certain file names while selectingData files coming in different names in a file name called

Data files coming in different names in a file name called process.txt. 1. shipments_yyyymmdd.gz 2 Order_yyyymmdd.gz 3. Invoice_yyyymmdd.gz 4. globalorder_yyyymmdd.gz The process needs to discard all the below files and only process two of the 4 file names available ... (1 Reply)
Discussion started by: dsravanam
1 Replies

10. UNIX for Beginners Questions & Answers

Renaming the file names in a directory

Hi, I have about 60 files in a directory and need to rename those files. For example the file names are i_can_phone_yymmdd.txt (where yymmdd is the date. i.e 170420 etc) i_usa_phone_1_yymmdd.txt i_eng_phone_4_yymmdd.txt The new file names should be phone.txt phone_1.txt phone_4.txt I am... (4 Replies)
Discussion started by: naveed
4 Replies
BUILDTORRENT(1) 						   User Commands						   BUILDTORRENT(1)

NAME
buildtorrent - a torrent file creation program. SYNOPSIS
buildtorrent [OPTIONS] -a announceurl input output buildtorrent [OPTIONS] -a announceurl -f filelist -n name output DESCRIPTION
buildtorrent is a torrent file creation program. Given an announce url and an input file or directory, buildtorrent generates an output .torrent file that can be used by torrent clients. OPTIONS
-a announce, --announce=url Announce URL (required). -f filelist, --filelist=filelist A text file (or - for standard input) containing a list of files to add to the output torrent file, together with the path to use inside the torrent. One file is given per line, use / as path separator for the torrent path, use | to separate the filesystem path from the torrent path. Backslash can be used to escape newlines and | characters inside names. For example: /data/files/linux.iso|bin/linux.iso /data/files/linux.txt|doc/linux.txt Using this option requires that the --name option be used. -n name, --name=name Specify the name for the torrent. Usage of this option is required when the --filelist option is used, in which case it specifies the name of the torrent directory. Usage without a file list overrides the name of the directory or file given on the command line. -A announces, --announcelist=announces Additional announce URL list. Use , to separate outer level lists, and | to separate inner level items; for example: a,b1|b2,c -w webseeds, --webseeds=webseeds Additional WebSeed URL list. Use , to separate items; for example: a,b,c -l length, --piecelength=length Piece length in bytes (default 262144). -L length, --piecesize=size Use 2^size as piece length (default 18) (overrides -l ). -c comment, --comment=comment User comment (omitted by default). -p private, --private=private Private flag (either 0 or 1). -D, --nodate Omit the creation date field. -C, --nocreator Omit the created by field. -m, --md5sum Add an md5sum field for each file. -s, --show Show generated torrent structure. -S, --showall Show generated torrent structure, including piece data. -q, --quiet Quiet operation with reduced output. -V, --version Show the version string. -h, --help Show a help screen with brief usage information. AUTHORS
Claude Heiland-Allen (claudiusmaximus@goto10.org) SEE ALSO
createtorrent(1), mktorrent(1) http://wiki.theory.org/BitTorrentSpecification http://bittorrent.org/beps/bep_0012.html http://www.getright.com/seedtorrent.html 0.8 January 2010 BUILDTORRENT(1)
All times are GMT -4. The time now is 06:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy