find digit which is greater than 1000 in text -using shellscript


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find digit which is greater than 1000 in text -using shellscript
# 1  
Old 09-26-2011
find digit which is greater than 1000 in text -using shellscript

Hi All,

I am having an abc.txt , which contains some digits

Eg:abc.txt

145
566
355

I want write shellscript in suchway that if any digit is greter than 1000 then it shuld display " text files contain digit, which is greater than 1000"


Please help me to do so

Thanks..
# 2  
Old 09-26-2011
What have you tried so far? Are you uncertain what tool to use? Or are you just hoping that we would do your work?
# 3  
Old 09-26-2011
Code:
for i in `cat abc.txt`
do
if [ $i -gt 1000 ]
then
echo " $i is greater than 1000" 
exit
fi
done

This User Gave Thanks to polineni For This Post:
# 4  
Old 09-26-2011
hi pspriyanka ..

I provided the solution na..
it will work
# 5  
Old 09-26-2011
Hi Pludi,

I have tried a lot .I know the grep command
Eg: grep exercise exercise.txt

but in above using grep command we can search only single word or digit

if i want to search the digit which is greter than 1000 then how to use this

I am new to this plz need ur help.

---------- Post updated at 05:27 PM ---------- Previous update was at 05:11 PM ----------

Hi Polineni,

Thanks a lot for helping me.

Need one more help which is not related to above

can u plz tell me how to use code tags , as u have used for posting the code here
# 6  
Old 09-26-2011
You should know more than one command to accomplish this, since you've already managed to create 35 posts and multiple user accounts (against the forums rules). Among these rules is that you should search the forums first for your question, so that there is less clutter. I suggest you do the same. I've moderated any other responses in this thread so far.

So please search for some keywords first, and only continue with this thread if you've got a specific problem with any of the possible solutions. We're not here to do your work, but to help you should you have troubles with anything you've learned.
# 7  
Old 09-26-2011
Code:
$ grep "[1-9]..." infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and substitute if greater than.

I have large config-files for an application. The lines have different structure, but some of them contains the parameter 'TIMEOUT=x', where x is an numeric value. I want to change the value for that specific paramater if the value is greater than a specific value (got that?). The timeout-parameter... (3 Replies)
Discussion started by: useless
3 Replies

2. Shell Programming and Scripting

Script to pull uid greater than 1000 from remote server

Hello, I am trying to get UID # greater than 1000 from all linux server, I tried this script getting this error message, someone please suggest. $for i in `cat hostlist.0709.org` ; do ssh -t $i 'awk -F':' "{ if($3 >= 1000) print $0 }" /etc/passwd ' >> output ; done $ cat output hostname1... (4 Replies)
Discussion started by: bobby320
4 Replies

3. Shell Programming and Scripting

find greater than value

Hi I want to find greater than and min value. dategrep() { varlinenum=$1 varSESSTRANS_CL="$(egrep -n "<\/SESSTRANSFORMATIONINST>" tmpsess9580.txt | cut -d":" -f1)" echo $varSESSTRANS_CL } dategrep 8 Output of the above command is: I want to find out greater than 8 and... (9 Replies)
Discussion started by: tmalik79
9 Replies

4. Shell Programming and Scripting

how to use use /usr/bin/find for 4 digit year dirs only

I have lots of directories in ~/. My diaries are stored in directories in ~/ containing exactly 4 digits. How do I use the /usr/bin/find command to only search my diary directories? So I would like my search to include ~/2009/abc/def and ~/2010/2001/33 but not ~/103/ or ~/20101/ or ~/201/... (2 Replies)
Discussion started by: siegfried
2 Replies

5. Shell Programming and Scripting

Script to find the string contain in which file 1000 files.

Hi Greetings i have 1000 files (xmlfiles) and i need to find which file contain the string over 1000 file all file end with txt i tried with grep -c "string" *.txt i am getting an error -bash: /bin/egrep: Argument list too long i have put an script like below #!/bin/bash for line... (9 Replies)
Discussion started by: venikathir
9 Replies

6. Shell Programming and Scripting

Find more then 1000 file at a time

Dear All, The need to found more than 1000 file are available in particular directory or not .That more than 1000 file stored in file.txt . i tried with locate & find command .But i can't get.pls post if any other option (1 Reply)
Discussion started by: kpoobathi
1 Replies

7. Programming

Find out 2^n+1 , where n is a 3 digit number

I have to write a c program which takes a 3 digit number n and calculates the value of (2^n)+1 and then determines the number is prime or not. I have tried to first calculate the value of 2^n and then adding one to it and then apply the logic of prime number. but the ultimate problem is that... (7 Replies)
Discussion started by: agrawal.prachi
7 Replies

8. Shell Programming and Scripting

Shellscript to find duplicates according to size

I have a folder which in turn has numerous sub folders all containing pdf files with same file named in different ways. So I need a script if it can be written to find and print the duplicate files (That is files with same size) along with the respective paths. So I assume here that same file... (5 Replies)
Discussion started by: deaddevil
5 Replies

9. Shell Programming and Scripting

shellscript to find a line in between a particular set of lines of a text file

i have a file a.txt and following is only one portion. I want to search <branch value="/dev36/AREA/" include="yes"></branch> present in between <template_file name="Approve External" path="core/approve/bin" and </template_file> where the no of lines containing "<branch value= " is increasing ... (2 Replies)
Discussion started by: millan
2 Replies

10. Shell Programming and Scripting

Find first digit in string using expr index

I have looked for hours for an answer, so I have decided to request your guidance. I want to substract the first number (series of digits) contained in a string. This string is the output of another command. The substring (number) can be located at any position inside the string. I want to... (4 Replies)
Discussion started by: jcd
4 Replies
Login or Register to Ask a Question