LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-14-2008, 04:31 AM   #1
naveensankineni
LQ Newbie
 
Registered: Feb 2008
Posts: 11

Rep: Reputation: 0
to print the files that ends with .sh extension


Hi ,

I need to get the list of files in the directory that doesn't end with .sql
extension

iam trying the follwing program but i couldn't


for j in `find $LOG_DIR -type f`
do

if [ `ls $j |grep .sql` != sql ]

{
then
echo "script $j doesn't ends with .sql extension"

}

the above logic is printing the filenames but the condition is not satisfying so can you please help me out.


Thanks,
Naveen.
 
Old 03-14-2008, 04:44 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
try
# dir="."
# find $dir -type f | grep -v '\.sql$'
 
Old 03-14-2008, 05:09 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
find $dir -type f -not -iname "*.sql"
 
Old 03-14-2008, 07:21 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
ls -I "*.sql"
add other options if necessary
 
Old 03-15-2008, 08:19 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
ls |grep -v '.sql'|lpr
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
.S extension for assembly files dogalmity Linux - Kernel 0 09-08-2006 09:07 AM
files the ends with .c maginotjr Programming 15 07-24-2005 01:06 PM
Extension files BC1 Linux - Software 5 12-20-2004 03:41 AM
What to do about these files with .new extension? Slovak Slackware 1 11-23-2004 04:50 PM
How program to read files with extension .dat y .cfg files COMTRADE in fedora 1? ivonne Linux - Software 0 11-22-2004 11:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration