How to search by File Name Length


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to search by File Name Length
# 1  
Old 06-25-2009
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  
Old 06-25-2009
many ways......
Code:
ls -1 | nawk 'length >20'

# 3  
Old 06-25-2009
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  
Old 06-25-2009
vgersh99 & jim mcnamara,

Thank You!
# 5  
Old 06-25-2009
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  
Old 06-25-2009
Quote:
Originally Posted by ymont
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. What is on Your Mind?

Updated Forum Search Index Min Word Length to 2 Chars and Added Quick Search Bar

Today I changed the forum mysql database to permit 2 letter searches: ft_min_word_len=2 I rebuilt the mysql search indexes as well. Then, I added a "quick search bar" at the top of each page. I have tested this and two letter searches are working; but it's not perfect,... (1 Reply)
Discussion started by: Neo
1 Replies

2. What is on Your Mind?

Updated Forum Search Index Min Word Length (Again)

For some reason, three char word lengths were not showing up in search results, even though the minimum is set to three and has been for a long time. After monkeying around with this, I turned off full page search, dumped all search indexes, and re-enabled full text search and it's working... (1 Reply)
Discussion started by: Neo
1 Replies

3. Shell Programming and Scripting

Search for a particular field length and append '0' if less less than 10

Hi, I am new to Unix. Please help me in finding solution for the below scenario. I have a flat file that contains data like 378633410|3013505414|new_378633410|ALBERT|WALLS|378633410|Rew||||||| 351049045|239|new_351049045|JIM|COOK|351049045|Rew|||||||... (6 Replies)
Discussion started by: anandek
6 Replies

4. Shell Programming and Scripting

Flat file-make field length equal to header length

Hello Everyone, I am stuck with one issue while working on abstract flat file which i have to use as input and load data to table. Input Data- ------ ------------------------ ---- ----------------- WFI001 Xxxxxx Control Work Item A Number of Records ------ ------------------------... (5 Replies)
Discussion started by: sonali.s.more
5 Replies

5. Shell Programming and Scripting

Search and replace particular characters in fixed length-file

Masters, I have fixed length input file like FHEAD0000000001XXXX20090901 0000009000Y1000XXX2 THEAD000000000220090901 ITM0000109393813 430143504352N22SP 000000000000RN000000010000EA P0000000000000014390020090901 TTAIL0000000003000000 FTAIL00000000040000000002 Note... (4 Replies)
Discussion started by: bittoo
4 Replies

6. Shell Programming and Scripting

search and replace fixed length record file

Hi I need to be search a file of fixed length records and when I hit a particular record that match a search string, substitute a known position field In the example file below FHEAD000000000120090806143011 THEAD0000000002Y0000000012 P00000000000000001234 TTAIL0000000003... (0 Replies)
Discussion started by: nedkelly007
0 Replies

7. UNIX for Dummies Questions & Answers

Convert a tab delimited/variable length file to fixed length file

Hi, all. I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file: 10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783 19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657 And this is the expected... (2 Replies)
Discussion started by: Everton_Silveir
2 Replies

8. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

9. Shell Programming and Scripting

Using awk to search variable length records

New to awk and need some help. I have a script that I would like to make more compact. I want to read a file and grab every field, from every record, except the last field. The records are variable length and have varying number of fields. A record will have at least two fields, but can have... (9 Replies)
Discussion started by: synergy_texas
9 Replies
Login or Register to Ask a Question