find 3 character long text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find 3 character long text
# 1  
Old 01-24-2012
find 3 character long text

I was trying to do some experiment with "sed".

I want to find the filenames which are three characters. So, this is what I have done to search for it, using sed.
Code:
sed -n -e '/^[a-z]\{3\}$/p' test

This returns the correct output for characters. But if I make change, let's say i create 2 more files 123 and 456. I cannot get the output that i wish to see with this command:
Code:
sed -n -e '/^[a-z]\{3\}$/,/^[0-9]\{3\}$/p' test.

even this does not work :
Code:
sed -n -e '/^[*]\{3\}$/p' test

All in all..it fails when I have numbers.. Is something wrong with the syntax?
I want to find all the files which are 3 characters long??

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data
# 2  
Old 01-24-2012
You mean sth like that? :
Code:
sed -n -e '/^[a-z0-9]\{3\}$/p' test

or even:
Code:
sed -n -e '/^.\{3\}$/p' test

# 3  
Old 01-24-2012
Wouldn't this suffice?

Code:
ls -1 | egrep "^.{3}$"

I didn't understand. Are you looking for files with 3 character long names or are you looking for strings in a file 'test' which are 3 characters long?
# 4  
Old 01-24-2012
If it's files in the current directory tree:

Code:
find . -type f -name \?\?\? -print

# 5  
Old 01-24-2012
Thanks for the reply..
Sorry... I wasn't that clear. I was not looking for files. Was looking for characters, and wanted to know about sed...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to put a 80 character limit on a long topic line in markdown?

I have a topic line in markdown that spans more than 80 characters that i need to add a line break. Markdown is simply treating the line break as a brand new line instead of continuing as a topic line. Eg: # This is a very long line Markdown interprets it as This is a very long line (4 Replies)
Discussion started by: dragonpoint
4 Replies

2. Shell Programming and Scripting

Find command take too long

Hi, I use the below script that will find n record the entire directory structure for a given folder. bash-3.2$ more mkdir.sh find . -type d |while read rec do echo "mkdir $rec" echo "chmod -R 777 $rec" #done done >> moht.sh The problem is the folder i m running this script... (10 Replies)
Discussion started by: mohtashims
10 Replies

3. Shell Programming and Scripting

Find character and Replace character for given position

Hi, i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command. thanks in advance, Sara (9 Replies)
Discussion started by: Sara183
9 Replies

4. Shell Programming and Scripting

find only 6 char long

find /tmp -type f -mtime +180 I have this script get the list to clean up files older than 180 days under /tmp. But, I want to make sure to grep only a type of files, which have only 6 character long. .... LT3hqa dRMoya ... (16 Replies)
Discussion started by: Daniel Gate
16 Replies

5. Shell Programming and Scripting

Awking string only 6 character long and providing a count

Morning Guys, I am attempting to awk a file which strings in the file is only 6 characters long and not more. Currently it is counting every line and giving a count of 59, but it should be 57 (not including the long baracode - 004705CIM*****) " awk '/./ {cnt++} END {print cnt}'... (11 Replies)
Discussion started by: Junes
11 Replies

6. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

7. Shell Programming and Scripting

sendmail long text

This is regarding sendmail. cat test.msg | sendmail -t In test msg I have the following. To: test@mymail.com Subject: Test Long text beings ... Now when I receive the email in Outlook I get an "!" inserted usually at position 990 and repeated mostly after every 990 chars or 65 chars.... (2 Replies)
Discussion started by: roadway
2 Replies

8. Shell Programming and Scripting

read the text file and print the content character by character..

hello all i request you to give the solution for the following problem.. I want read the text file.and print the contents character by character..like if the text file contains google means..i want to print g go goo goog googl google like this Using unix Shell scripting... without using... (1 Reply)
Discussion started by: samupnl
1 Replies

9. Shell Programming and Scripting

Find/Change long text

If I have very large text file *************** *************** *************** *************** *************** ABC-sdfsdf BBB-xk[ptr'; CCC-sdfolb ABC-dltg'fl;l My aim: -> tail last 10 lines from large text. ***** Ok ***** -> Change first 3 charactors which begin with "ABC" to "abc".... (1 Reply)
Discussion started by: aungomarin
1 Replies

10. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies
Login or Register to Ask a Question