Grep Too Many Arguments Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about too many arguments in shell script Stack Overflow the company Business Learn more about hiring developers or posting ads with
Too Many Arguments Bash
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is too many arguments error in linux a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How can I grep while avoiding 'Too many arguments' [duplicate] up vote 1
Cd Too Many Arguments
down vote favorite 2 This question already has an answer here: Argument list too long error for rm, cp, mv commands 19 answers I was trying to clean out some spam email and ran into an issue. The amount of files in queue, were so large that my usual command was unable to process. It would give me an error about too many arguments. I usually do this grep -i grep argument list too long workaround user@domain.com 1US* | awk -F: '{print $1}' | xargs rm 1US* can be anything between 1US[a-zA-Z]. The only thing I could make work was running this horrible contraption. Its one file, with 1USa, 1USA, 1USb etc, through the entire alphabet. I know their has to be a way to run this more efficiently. grep -s $SPAMMER /var/mailcleaner/spool/exim_stage1/input/1USa* | awk -F: '{print $1}' | xargs rm grep -s $SPAMMER /var/mailcleaner/spool/exim_stage1/input/1USA* | awk -F: '{print $1}' | xargs rm linux bash grep share|improve this question asked Apr 18 '13 at 15:18 Justin S 14338 marked as duplicate by tripleeebash Users with the bash badge can single-handedly close bash questions as duplicates and reopen them as needed. Oct 6 '15 at 5:13 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. add a comment| 5 Answers 5 active oldest votes up vote 2 down vote accepted Run several instances of grep. Instead of grep -i user@domain.com 1US* | awk '{...}' | xargs rm do (for i in 1US*; do grep -li user@domain "$i"; done) | xargs rm Note the -l flag, since we only want the file name of the match. This will both
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Grep Large Number Of Files
policies of this site About Us Learn more about Stack Overflow the
Bin Grep Argument List Too Long
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags too many arguments excel Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes http://stackoverflow.com/questions/16086834/how-can-i-grep-while-avoiding-too-many-arguments a minute: Sign up Bash: Meaning of “[: too many arguments” error from if [] (square brackets) up vote 73 down vote favorite 25 I couldn't find any one simple straightforward resource spelling out the meaning of and fix for the following BASH shell error, so I'm posting what I found after researching it. The error: -bash: [: too many arguments http://stackoverflow.com/questions/13781216/bash-meaning-of-too-many-arguments-error-from-if-square-brackets Google-friendly version: bash open square bracket colon too many arguments. Context: an if condition in single square brackets with a simple comparison operator like equals, greater than etc, for example: VARIABLE=$(/some/command); if [ $VARIABLE == 0 ]; then # some action fi bash if-statement arguments share|improve this question edited Aug 22 at 14:40 asked Dec 8 '12 at 19:46 user568458 8,37764867 1 Where is the code that produced this specific error? –Anderson Green Jun 17 '13 at 22:39 2 Thank you for the Google-friendly version :) –cchan3141 Aug 11 at 7:51 add a comment| 2 Answers 2 active oldest votes up vote 144 down vote accepted If your $VARIABLE is a string containing spaces or other special characters, and single square brackets are used (which is a shortcut for the test command), then the string may be split out into multiple words. Each of these is treated as a separate argument. So that one variable is split out into many arguments. The same will be true for any function call that puts down a string containing spaces or o
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about http://unix.stackexchange.com/questions/162616/why-am-i-getting-too-many-arguments hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join http://www.linuxquestions.org/questions/programming-9/%5B-too-many-arguments-error-in-an-if-statement-565710/ them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Why am I getting “too many arguments” up vote too many 2 down vote favorite Here's a part of my script that is telling me that I have too many arguments on line 3: #!/bin/bash export LC_ALL='C' if [ `echo "*file 2" | grep -o ^.` = '.' ] then echo success fi Anybody know why? As far as I can tell, I'm just comparing two arguments, "*" and "." shell-script arguments test share|improve this question edited Oct 16 '14 at 23:40 HalosGhost 3,02261733 asked Oct 16 '14 at 23:34 Aaron too many arguments 1513 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted echo "*file 2" | grep -o ^. prints *. Since you have a command substitution outside double quotes, it undergoes globbing (a.k.a. wildcard matching a.k.a. filename generation) and word splitting. If the current directory is not empty, * expands to the list of files in the current directory. Each file becomes one token in the [ command, which is highly likely to be a syntax error. The problem is that you didn't use double quotes around the command substitution. Always use double quotes around variable and command substitutions unless you have a good reason to omit them. if [ "$(echo "*file 2" | grep -o ^.)" = '.' ] See Why does my shell script choke on whitespace or other special characters? for a more detailed explanation. share|improve this answer answered Oct 16 '14 at 23:39 Gilles 372k696751126 Thanks, I'm still new to shell scripting, so all help is appreciated! –Aaron Oct 17 '14 at 0:19 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other question
Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Non-*NIX Forums > Programming "[: too many arguments" Error In An If Statement User Name Remember Me? Password Programming This 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. Are you new to LinuxQuestions.org? Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now 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. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click