The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Convert a tab delimited/variable length file to fixed length file Everton_Silveir UNIX for Dummies Questions & Answers 2 12-19-2008 06:21 PM
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 9 12-04-2008 04:04 PM
Using awk to search variable length records synergy_texas Shell Programming and Scripting 9 08-22-2008 01:46 AM
creating a fixed length output from a variable length input r1500 Shell Programming and Scripting 2 12-03-2003 01:09 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-25-2009
ora_umair ora_umair is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 24
Question How to search by File Name Length

Hi, All -

How can I search a directory for files with names over 20 characters in lenght?

Thanks in advance!
  #2 (permalink)  
Old 06-25-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
many ways......
Code:
ls -1 | nawk 'length >20'
  #3 (permalink)  
Old 06-25-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
One way:
Code:
#!/bin/ksh
# myscript.sh
filename=$(basename "$1")
[[ ${#filename} -gt 20 ]] && echo "$1"
Code:
find /directory -type f -exec /path/to/myscript.sh {} \;
An external script works as an argument to -exec
  #4 (permalink)  
Old 06-25-2009
ora_umair ora_umair is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 24
vgersh99 & jim mcnamara,

Thank You!
  #5 (permalink)  
Old 06-25-2009
ymont ymont is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 1
File search

Hi Gurus,

Please help im new in UNIX, got exercise but im stuck.
How to:
1- List all files (file names only) that contain "xynos" but not the word "troi" in the filename.
2- List all files in date/time order (full listing) that contain "xynos" but not the word "troi" and "dvoika" in the filename.
3- View all file one by one in the vi editor that contain "xynos"..

thanks in advance..

Yves
  #6 (permalink)  
Old 06-25-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
Quote:
Originally Posted by ymont View Post
Hi Gurus,

Please help im new in UNIX, got exercise but im stuck.
How to:
1- List all files (file names only) that contain "xynos" but not the word "troi" in the filename.
2- List all files in date/time order (full listing) that contain "xynos" but not the word "troi" and "dvoika" in the filename.
3- View all file one by one in the vi editor that contain "xynos"..

thanks in advance..

Yves
Don't:
  1. Post homework assignments - it's against the rules
  2. Hijack other people threads - start your own
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0