ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i want to delete all files in my directory that have 5 lines ......
(means all files that are 5 lined, but not empty files)
i used for loop inside wic i gav wc -l and then if it is 5 then remove it......but some silly syntax error.....
i knw that we can use sed for this.....
i am using that sed command wc -l * | sed -n 's/ \+5 //p'
but my entries are around 3000.....so its giving arguement list too long......
i als tried givin it in loop......
Ok, I've let myself get a bit confused. I thought I recall \+, but I must be mistaken. BREs have no support for the + char (1 or more chars). Extended REs provide + support, and no \ is required.
The 5 char is simple the output of wc, btw., not part of any metacharacter or quantifier. The sample code in post #2 does not work for me on BSD or Linux.
everthinng s fine, but i am gettin bugs due to the number of files I have.....
Dear burschik, Mr.C, kenoshi....
i acknowledge your help, but for finding the 5lined files and then removing them, i hav around 3000 files to check and its priting a bug like arguement list too long......so i am using a loop to gind and remove....
plz suggest the proper code for this....
find . -type f | xargs wc -l | sed -n 's/ 5 //p' is working fine...but to remove the same, how??
Correct me if I'm wrong...I thought with BREs meta characters such as . * ^ $ doesn't require an escape, while all others do...and EREs you don't need to escape any of the metas.
Anyway, grats raghu123, nothing like figuring things out yourself
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.