Differences between revisions 10 and 12 (spanning 2 versions)
Revision 10 as of 2008-01-31 17:38:52
Size: 27336
Editor: GreyCat
Comment: added cptmorgan; added table of contents and subheaders
Revision 12 as of 2008-02-07 22:17:39
Size: 32506
Editor: GreyCat
Comment: add commentary
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:

 ''This conversation happened before greybot was updated with the `> name` feature. It was pretty commonplace. General rule: if an answer is given immediately after your question is asked, there's a pretty good chance the answer is for you!''
Line 47: Line 49:

 ''You didn't see the '''zald:''' on the front of the line? Try using a client that highlights lines with your name on them.''
Line 91: Line 95:
 ''We don't have some super secret stash of knowledge that we hide until you ask 14 times. Really. Just accept the answer.''
Line 103: Line 109:

 ''Another example of people not reading the answers. At least he was reasonably polite.''
Line 150: Line 158:

 ''Unfortunately, time stamps weren't saved with this one. Despite being told repeatedly, I440r persisted in his statements that we were wrong. From my point of view, his comment of '''yes''' immediately followed, and was in response to, my comment of '''I440r: it doesn't.'''. Directly contradicting me like that doesn't tend to win my favor.''
Line 215: Line 225:

 ''No comment needed on this one.''
Line 297: Line 309:
 ''Here we see a very common pattern from #bash. Someone comes in with a superficially simplistic-looking question that masks a deeper problem. I can see right through the mask. I '''know''' there's another, deeper problem waiting in the wings, and I try my best to solve '''that''' problem instead of the one they asked. Yet, here (as is commonly the case) the person asking the question was mired so deep in their mistakes that they weren't willing to step back and look at the big picture. Oh well. Their loss.''
Line 307: Line 321:

 ''Moderately obscure pop culture references go right over his head.''
Line 347: Line 363:

 ''"Unhelpable." I still stand by that one even after reviewing this.''
Line 421: Line 439:
 ''These two have a history of conflict. Not quite sure who was the "idiot" here, since I didn't post this one.''
Line 481: Line 501:

 ''"You mean you want to do '''this'''?" "Exactly." "Well, then you do it like this...." "That won't work for what I have to do." ... '''That means you lied to me when you said my example was "exactly" right!''' Argh! Make up your mind!''

== x86 vs. greycat ==
{{{<x86> I'm trying to find files older than 30 days
<greycat> !find > x86
->#bash x86: http://wooledge.org/mywiki/UsingFind
<felipe_> teh scrip command?
<x86> so I do find /path -mtime 30
<savetheWorld> felipe_: "script"
<x86> but I get nothing
<greycat> x86: -30 not 30
<greycat> oops.
<greycat> x86: +30 not 30
<x86> even if I do find /path -mtime 1
<x86> greycat: thanks
<greycat> !find > x86
->#bash x86: http://wooledge.org/mywiki/UsingFind
<x86> now is ctime basically "create" time?
<trash> no
<savetheWorld> !ctime
->#bash ctime is NOT creation time! It's (metadata) change time. It's updated whenever a file's ownership, permissions, etc. change. Unix does not store creation time of a file ANYWHERE, at all. There is no way you can possibly know when a file was created, unless you're on a system with nonstandard file system extensions.
<x86> greycat: seems if I do: "find /path -mtime +30 -exec rm {} \;" I get "missing argument to '-exec'"
<greycat> x86: You did not get that error from that command. Try again.
<trash> x86: what system are you on?
<lhunath> ppc.
<greycat> At least, you didn't get that error from that command in a Bourne family shell.
<x86> ah, i was missing the \; ;)
<x86> thanks guys
<lhunath> eval "find /path -mtime +30 -exec rm {} \;" <- that might cause it.

...

<x86> say each line of a file contains a file name, some of which may have spaces
<x86> it seems when I do "for x in `cat ${file}`", it makes the names with spaces into two distinct entries
<greycat> !faq 1 > x86
->#bash x86: http://wooledge.org/mywiki/BashFAQ/001 -- How can I read a file line-by-line?
<greycat> !find > x86
->#bash x86: http://wooledge.org/mywiki/UsingFind
<x86> greybot: not using find this time ;)
<greycat> It just *happens* to be *identical* to the output of find.
<greycat> But you're not using find.
<greycat> Right.
<x86> greycat: I use find to generate the file, then I use a for loop to parse it
<greycat> Don't.
<x86> just telling you i'm not using find to do the second part ;)
<x86> while read looks good
<greycat> I'm just telling you you're a moron.
<x86> greycat: becasue I didn't know how to do it better somehow I'm a moron?
<x86> nice methodology
<greycat> *plonk*
<x86> really prognostic
<greycat> It's not like I FAILED to give you all the relevant URLs as soon as you started asking the question.
<x86> greycat: you gave me the correct URLs and I'm reading them
* greycat guesses x86 was too busy regurgitating his crappy problem instead of reading the URLs provided.
<x86> greycat: and I even mentioned I'll move to while read, like your URL said
<x86> wow man nice attention span...
<x86> you totally missed that I guess ;)}}}

 ''Once again, there's a deeper problem that the person asking the question refuses to address. They've made a mistake already, and even when that mistake is pointed out, they refuse to step back and take a different path to avoid it. They '''demand''' that we tell them the next step which will somehow magically cancel out their original mistake. Extremely frustrating.''

You -- yes, you -- are an idiot!

Here are some other idiots in whose company you may find solace.

TableOfContents

SpaceBass vs. greycat

{{{SpaceBass> hey folks, I have a backup script I'm working on... have a TEMPDIR var that has "/Vol/Disk 2/Backups" but for some reason then I use $TEMPDIR in my tar command its not escaping the space in the disk name (which I cannot change) greycat> !quotes greybot> USE MORE QUOTES! http://www.grymoire.com/Unix/Quote.html ernstable> !quotes greybot> USE MORE QUOTES! http://www.grymoire.com/Unix/Quote.html ernstable> too slow SpaceBass> I've tried using /Vol/Disk\ 2/Backups in the variable but that didnt help either greycat> Try quotes. SpaceBass> was the quotes comment directed at me?}}}

  • This conversation happened before greybot was updated with the > name feature. It was pretty commonplace. General rule: if an answer is given immediately after your question is asked, there's a pretty good chance the answer is for you!

zald vs. greycat

{{{zald> how do i put \n for each line it output on this command " foovar=cat var; echo $foovar greycat> !pitfalls greybot> http://wooledge.org/mywiki/BashPitfalls greycat> !quotes greybot> USE MORE QUOTES! http://www.grymoire.com/Unix/Quote.html zald> payal, what is the proper way? zald> because the output is in online line greycat> zald: pitfalls. quotes. zald> status1=cat accesslist | grep -v -x $ipaddress1 ; greycat> specifically the pitfall whose content is echo $foo redduck666> !uuoc greybot> Useless Use of Cat (cat foo | grep bar). See <http://www.ruhr.de/home/smallo/award.html>. greycat> redduck666: you win that one :) redduck666> :) zald> what will i use then to replace cat greycat> Do you actually READ anything we tell you to read?! zald> sorry let me check greycat> hmm, actually the uuoc page assume the reader is not ignorant. zald> thank you so much payal, i just put an echo "$foo" , instead of echo $foo zald> thanks for the links greycat> My. Fucking. God. greycat> we told you THREE TIMES and then you thanked her.... floyd_n_milan> payal, meh give it a rest already floyd_n_milan> you guys should both just *plonk* each other you know greycat> at the moment, I'm just pissed off at that zald idiot for NOT reading the pitfalls page when I told him to (I even told him **which one to read**!) zald> im not aware that you are talking to me then greycat}}}

  • You didn't see the zald: on the front of the line? Try using a client that highlights lines with your name on them.

payal vs. greycat

{{{payal> How can I make a float into integer payal> I have a number 5.6122211 - I want to compare it with a value in $var greycat> !faq float greybot> http://wooledge.org/mywiki/BashFaq#faq22 -- How can I calculate with floating point numbers instead of just integers? payal> I have no bc and don't want to use awk - and I don't want a very precise answer greycat> If you don't care about precision, just echo 0 every time. payal> I have 5.6122211 in a variable $b and just want to know whether it is smaller or greate than $var - nothing much greycat> !faq float greybot> http://wooledge.org/mywiki/BashFaq#faq22 -- How can I calculate with floating point numbers instead of just integers? payal> ((4.3 < 2.4)) && echo Success payal> bash: ((: 4.3 < 2.4: syntax error in expression (error token is ".3 < 2.4") greycat> !faq float greybot> http://wooledge.org/mywiki/BashFaq#faq22 -- How can I calculate with floating point numbers instead of just integers? payal> greycat: I already read that the first time - that is why I said I don payal> t want to use bc or awk greycat> *plonk* *plonk* trash> payal: bash cannot handle float numbers. use external tools. trash> !faq float greybot> http://wooledge.org/mywiki/BashFaq#faq22 -- How can I calculate with floating point numbers instead of just integers? trash> the 3rd time now. greycat> trash: hence the *plonk*ing. She's the most stubborn person I've ever seen here. trash> greycat: it's not the first time redduck666> payal: if you are willing to settle for a simple string comparison you can use $b > $var redduck666> payal: i said it is a string comparison :) floyd_n_milan> !math greybot> http://wooledge.org/mywiki/ArithmeticExpression floyd_n_milan> payal, that? greycat> floyd_n_milan: is she still asking about doing floating point comparisons? floyd_n_milan> greycat, lol apparently floyd_n_milan> payal, yeah, floating points not possible in bash greycat> She's been given the FAQ entry at least 5 times now. floyd_n_milan> mhmmm redduck666> payal: there is no native way to do that in bash. you could break up the string in part before '.' and the part after '.' and than compare the two floyd_n_milan> payal, are you interested in seriously learning bash floyd_n_milan> payal, i don't doubt, i was just asking floyd_n_milan> payal, read the O'Reilly book - Learning the bash shell, 3rd edition and then read man bash, practise and then check out the ABS guide on TLDP floyd_n_milan> yeah it explains the basics nicely floyd_n_milan> payal, meh give it a rest already overrider_> payal, dude floyd_n_milan> correction, dudette overrider_> payal, you be either kicked or plonked}}}

  • We don't have some super secret stash of knowledge that we hide until you ask 14 times. Really. Just accept the answer.

janson_ vs. greycat

{{{janson_> i have many files, named like '6540141.jpg 6540157.jpg 6540165.jpg' and i will check the two last digits (41,57,65) and move them into the dir with the same name. What will be the best commands to use for this? janson_> i think the easiest is to use find and something more janson_> mv ofc :D janson_> but i will need to use regexp i suppose greycat> for file in *.jpg; do x=${file%.jpg}; n=${x: -2}; echo mv "$file" $n; done koala_man> !pe greybot> Parameter Expansion. Expressions like ${foo%.mp3} and so on -- see man bash, and then search for Parameter Expansion. See also, http://wooledge.org/mywiki/BashFaq#faq74 and http://tiswww.tis.case.edu/~chet/bash/bashref.html#SEC30

  • [... 14 minutes later ...]

janson_> find . -type f -name "*.jpg*" , now i need to cut out "51" in the file named "xyz51.jpg", how can i use parameter expansion for this? greycat> janson_: my complete solution wasn't good enough for you? janson_> greycat: ow, missed it. thanks}}}

  • Another example of people not reading the answers. At least he was reasonably polite.

I440r vs. greycat

{{{I440r> is it possible to redirect an echo of a here document to a file? greycat> yes. greycat> except that you don't "echo" a here document. I440r> like echo << zzz stuff sss >> foo isnt working for me greycat> !pitfalls greybot> http://wooledge.org/mywiki/BashPitfalls greycat> Amazing how many times that one pops up. I440r> lol. how would yo do that then? cat? greycat> Yes. Read. greycat> I write these wonderful pages just for people with questions like yours. flippo> echo doesn't handle an input stream I440r> lol we appreciate it :) I440r> can i have things like $1 in the here document? flippo> It's easy to find out %] greycat> I440r: yes. read the man page. greycat> you should be able to find << very easily flippo> Or "try it and see" (TM) greycat> Here, I think the bot even has it. greycat> !<< greybot> Here documents. cat <<EOF followed by several lines of text, followed by the literal string EOF on a new line, NOT indented. The portion between the EOFs is passed to the command as standard input. If 'EOF' is 'quoted', substitutions WON'T be done; usually they are. I440r> ok the cat of teh here document worked but it echo'd it to the dispay the >> some.file didnt work greycat> you probably put the >>output in some random location rather than on the cat command. I440r> i put it after the end marker of teh here document greycat> I440r: that is why you fail greycat> redirection operators apply to commands, not to data I440r> ok... where should it have gone? ive not seen any examples of this greycat> 12:27 greycat> you probably put the >>output in some random location rather than on the cat command. I440r> ok, how do i stop it echoing the end marker of teh here document? greycat> I440r: it doesn't. greycat> You're doing something wrong. I440r> it is I440r> yes greycat> Fucking STOP lying to us, or POST the god damned code so we can point out your mistakes a FOURTH fucking time. I440r> wtf I440r> i jsut FUCKING said "YES I440r> " greycat> imadev:~$ cat <<EOF >>foo greycat> > blah blah blah greycat> > EOF greycat> You have new mail in /net/home/wooledg/Maildir/ greycat> imadev:~$ cat foo greycat> sdfkjshd not found greycat> blah blah blah - I440r [n=mark4@70.102.202.164] left #bash () greycat> Note that I already had a file named "foo" with that one line in it.}}}

  • Unfortunately, time stamps weren't saved with this one. Despite being told repeatedly, I440r persisted in his statements that we were wrong. From my point of view, his comment of yes immediately followed, and was in response to, my comment of I440r: it doesn't.. Directly contradicting me like that doesn't tend to win my favor.

hhellpme vs. greycat

{{{<hhellpme> how do i call a variable inside a sed command? <greycat> !quotes ->#bash USE MORE QUOTES! http://www.grymoire.com/Unix/Quote.html <igli> !huh ->#bash What are you really trying to do? In a sentence or two please. Not which tool you think is the right one to use, and what you are trying to do with it. Just the actual task at hand. <hhellpme> is this bash shell scripting? <igli> yup <greycat> didn't the quotes page help you? <greycat> learning when to use " vs. ' is essential, especially for your question <hhellpme> sed: -e expression #1, char 5: Unterminated `s' command <--this is what i got when this code is being ran http://www.pastebin.ca/479121 <igli> read the doc pointed out first <greycat> 1. i=100 <greycat> 2. s=expr $i + 1 <greycat> 3. sed '$sq;d' mytextfile <greycat> !quotes ->#bash USE MORE QUOTES! http://www.grymoire.com/Unix/Quote.html <greycat> 11:41 greycat> learning when to use " vs. ' is essential, especially for your question <igli> and then give us just the sed line <igli> yeah you need " <greycat> I un-pastebinned it for you. <greycat> After you're done reading that, you might want to read? <igli> that is rare ;) <greycat> !math ->#bash http://wooledge.org/mywiki/ArithmeticExpression <greycat> since your code doesn't have a shebang line, we don't know whether you're using bash or sh, so... we can't say for sure. <greycat> oh, and you'll almost certainly want this one too: <greycat> !faq concat ->#bash http://wooledge.org/mywiki/BashFAQ#faq13 -- How can I concatenate two variables? How do I append a string to a variable? <hhellpme> im sorry im using bash <go|dfish> heh <greycat> then read quotes, math, and #13. <hhellpme> im still puzzled <hhellpme> which is which <igli> put #!/bin/bash at top of your script to be sure <igli> man where's that link <greycat> !shebang ->#bash http://homepages.cwi.nl/~aeb/std/shebang/ <igli> http://mikeash.com/getting_answers.html <igli> read that please hhellpme <hhellpme> yeah i did #!/bin/bash im pretty sure i dont know what to place inside sed to call the variable <greycat> !learn answers http://mikeash.com/getting_answers.html ->#bash OK, greycat <greycat> hhellpme: read "quotes" <igli> please read that doc before we go any further <greycat> I also placed a subtle hint in that last line. <greycat> I also told you twice. <igli> "Sometimes a real moron will reply to you, and sometimes you'll get a smart guy who's having a bad day or who didn't correctly read your question. However, most of the time you'll be talking to people who know more about the subject at hand than you do (that's why you came to them for help in the first place, remember). As such, it pays to at least entertain the possibility that they know what they're talking about." <greycat> Is that one from a web page somewhere? <igli> same page <greycat> ah. maybe I should read the whole thing. <igli> fed up of the noise tbh ;) <hhellpme> im trying to read the sites you gave <igli> cool :) <igli> hhellpme: <igli> yeah you need " <greycat> igli: I also said, twice, that one needs to know when to use " instead of ' <igli> yeah i know greycat ;)

<hhellpme> i really cant get it <greycat> REPLACE THE MOTHER-HUMPING ' WITH " <greycat> THEN REPLACE THE FUCKING sq WITH {s}q <redondos> lol}}}

  • No comment needed on this one.

ideasman_42 vs. greycat

{{{<ideasman_42> so is there any way to get the current directory of the running script? <ideasman_42> (from thin the script) <ideasman_42> #!/bin/bash <greycat> the current working directory is $PWD <ideasman_42> echo ...running in this dir... <greycat> the location of the script is unavailable and in many cases meaningless because the script does not even exist.... <greycat> echo "running in $PWD" <ideasman_42> yeah, but that dosnt work because if you launch the script from another dir <mikmor1> ideasman_42: you can try $(cd dirname $0; pwd) <greycat> what do you ACTUALLY want? <ideasman_42> I want the path the script its self is in <greycat> !faq location > ideasman_42 ->#bash ideasman_42: http://wooledge.org/mywiki/BashFAQ#faq28 -- How do I determine the location of my script? I want to read some config files from the same place. <greycat> Why? <ideasman_42> because there is a binary in the same dir <ideasman_42> arg, was looking directory as keyword <greycat> put them both in /usr/local/bin instead. <greycat> problem solved. <ideasman_42> no <ideasman_42> its not so simple <greycat> (Oh, how dare you, greycat?! You can't actually suggest that people do NORMAL, SENSIBLE things!! You have to feed their need to do weird l33t things that make no sense instead! Especially impossible ones!) <ideasman_42> blender3d is distributed as a tarball at the moment <mikmor1> ... <mikmor1> does mine not work for you? <greycat> so fucking install it. <ideasman_42> its file structure works the same on all OS's at the moment <ideasman_42> so its not that unixy <ideasman_42> anyway, it dosnt install into /usr/bin etc <greycat> who cares? <ideasman_42> just extracts and runs <greycat> you mean it installs itself somewhewre. <ideasman_42> well I care because I want a few things to be improved <ideasman_42> it dosnt even install on unix at the moment <ideasman_42> just unpack and run the tarball <greycat> then I don't see what the bash question is. <ideasman_42> well, if you unpack and run, the binary dosnt know where it is- <ideasman_42> its a problem on unix <greycat> wait, "unpack and run the tarball"? you mean, "unpack the tarball" (also known as INSTALLING THE FUCKING THING) and then run it? <greycat> isn't that what I said to do in the first place? <greycat> install it? and then run it? <ideasman_42> no <greycat> what happens when you untar it? <ideasman_42> because it dosnt sit in the normal /usr/bin etc.. <greycat> WHO CARES? <greycat> what happens when you untar it? <ideasman_42> you get a binary and some config files <greycat> in the current working directory, yes? <ideasman_42> yeah <greycat> so then what you do as a Unix system administrator is DECIDE WHERE YOU WANT IT TO BE, and then untar it there. <ideasman_42> right, and that works <ideasman_42> except for people who untar and run, it ALMOST works <ideasman_42> but there are some glitches <greycat> e.g., "Hey! I think it should be in /opt/blender3d!" mkdir /opt/blender3d && cd "$_" && tar xzvf /path/to/blender3d.tar.gz <ideasman_42> so Id like to make it work better <greycat> When you have done THAT, then you might be able to formulate a bash question. <greycat> For instance, "I have an application that must be executed from the /opt/blender3d directory, but I want to be able to simply type "blender" from anywhere and have it run..." <greycat> And then we could answer that. <ideasman_42> I want the extracted files to run anywhere - self contained <greycat> That answer would probably look something like, Put the following script in /usr/local/bin and name it "blender": #!/bin/sh cd /opt/blender3d || exit 1; ./blender3d "$@" <ideasman_42> no hard coded /opt or /usr stuff <greycat> Fuck off. <greycat> *plonk* <ideasman_42> ? <greycat> le3t fucking god damned twits.... <ideasman_42> this is how it works in windows <ideasman_42> and there are good reasons to do it this way <ideasman_42> for example there are multiple branches developed at the moment <ideasman_42> and people cant properly test these branches if they use global dirs <ideasman_42> its not about being leet <ideasman_42> its about making software that does not fit the unix file layout, run in unix without problems <ideasman_42> ok, the solutions listed involve searching the path <ideasman_42> and that wont work in this case <ideasman_42> since it isnt always in the path <greycat> since I'm capturing this part of the log to post on my Idiots page, and I happened to see the lines you wrote after I /ignored you, let me respond thus: <greycat> Make /usr/local/bin/blender-head contain #!/bin/sh cd /opt/blender3d-head && ./blender3d "$@" <greycat> Make /usr/local/bin/blender contain #!/bin/sh cd /opt/blender3d && ./blender3d "$@" <greycat> etc. <greycat> Or is that not complex enough? <ideasman_42> its too simple}}}

  • Here we see a very common pattern from #bash. Someone comes in with a superficially simplistic-looking question that masks a deeper problem. I can see right through the mask. I know there's another, deeper problem waiting in the wings, and I try my best to solve that problem instead of the one they asked. Yet, here (as is commonly the case) the person asking the question was mired so deep in their mistakes that they weren't willing to step back and look at the big picture. Oh well. Their loss.

igli vs. greycat

{{{<streuner> hm <igli> !hi ->#bash Hi, and don't ask to ask ;) <kojiro> uh, what? <kojiro> m != i <greycat> igli's lonely and in the mood for some 'bot lovin' again <igli> greycat: yes, dear ;) <greycat> You've got metal fever, boy! <igli> ffs, who you calling boy? when did you first write a line of C, little man?}}}

  • Moderately obscure pop culture references go right over his head.

bbots_guest40 vs. greycat

{{{<bbots_guest40> hi <bbots_guest40> how to fix my shell <go|dfish> r u a bot? <twkm> hmm. <bbots_guest40> someone used bash in my shell <bbots_guest40> my <bbots_guest40> host changed pass keep them out <greycat> oh no, not bash!?! <bbots_guest40> please <greycat> Speak coherently. Ask a question that makes sense. <greycat> If you can't think of words, start with "I'm trying to ..." <bbots_guest40> greycat how do i fix it? <greycat> Fix what? <greycat> You haven't even said what's broken yet. <bbots_guest40> i have <bbots_guest40> bash errors. <bbots_guest40> my files are still here.. <bbots_guest40> but it shows bash instead of my username. <greycat> "I'm trying to..." "The error message is: ..." <trash> oh no, his $PS1 is gone! <bbots_guest40> greycat, first message was when i login bash auto close my putty <bbots_guest40> fixed that but now i enter commands ir dont accept them. <greycat> Unhelpable. <greycat> "When I type .... the computer says ...." <bbots_guest40> ls <greycat> Paste ACTUAL OUTPUT. Do not type vague descriptions. <bbots_guest40> neostats unreal.config etc.. <greycat> So the ls command works? Good. <bbots_guest40> bash errors <twkm> to fix bash use an admin. <greycat> Fucking HELL. I'm getting VERY tired of you. <greycat> Paste EXACTLY what the fuck the error is, or go away. <bbots_guest40> i'm root <greycat> You shouldn't be root. You're not intelligent enough. <bbots_guest40> greycat i'm on internet chat <greycat> Not with me any more. *plonk* <bbots_guest40> what servr! <go|dfish> 'bbots - (B)ash (BOT) (S)cripts. IRC bots written in bash. The bots are self contained and have everything needed to load and run. More modules and development on http://bashscripts.org'}}}

  • "Unhelpable." I still stand by that one even after reviewing this.

igli vs. go|dfish

{{{<gladier> hey guys - need a quick hand playing with getopt ... isnt making any sense to my head <gladier> want to parse a -s flag and if it contains anything set a var to its contents <twkm> while getopts s: in s) var=$OPTARG;; ?) echo invalid option;; esac; shift $((OPTIND-1)) <twkm> bah, while getopts s: foo; do case $foo in ... esac; done; shift ... <gladier> shouldnt there be a case before the esac? <igli> second one <twkm> yes there should be, see the mock revision. <gladier> while getopts s: foo; do case $foo in s) var=$REV;; ?) echo invalid option;; esac; done; seems to set my var to ? <igli> var=$OPTARG;; <igli> as twkm said <twkm> wtf did you do to my OPTARG? <twkm> OPTARG is not a random name. var is. (as is foo). <twkm> given options of -s abc my (corrected) example would set var to abc. <gladier> aha! success <gladier> constraints of numbers and periods on a variable? <igli> nice idea <igli> !faq valid <greybot> http://wooledge.org/mywiki/BashFAQ#faq54 -- How can I tell whether a variable contains a valid number? <twkm> man bash, definitions section. <gladier> alright .. have it implemented properly but im not entirely sure on my test in the if statement. seems to do funny things. http://pastebin.com/d3f2a6e8f <Gekz> lol <gladier> wth are you doing in here Gekz <igli> hehe <Gekz> i'm everywhere <igli> you need to move the code handling OPTARG into the case branch <igli> ![[ <greybot> [[ is a shell keyword similar to (but more powerful than) the [ command. See http://wooledge.org/mywiki/BashFAQ#faq31 and http://wooledge.org/mywiki/BashGuide#Bash_Tests Unless you are scripting for POSIX sh we recommend [[. <igli> !basename <greybot> basename removes everything except the rightmost word in a path expression. In modern times we use parameter expansion, like "${var##*/}". (Yes, parameter expansion can also remove the file's extension. See !pe.) <go|dfish> gladier: ALWAYS check 'cd' executes successfully. <igli> !quotes > gladier <greybot> gladier: USE MORE QUOTES! Read http://bash-hackers.org/wiki/doku.php?id=syntax:words to understand why. http://www.grymoire.com/Unix/Quote.html will tell you how. -- Optimally, you should quote every parameter expansion ($foo). <go|dfish> FUCKING HELL <go|dfish> JESUS FUCKGIN CHRIST <igli> that is the most important one imo <gladier> shush ... its a quick and dodgey script <igli> cp -r $DIR $DIR-$SVN-1 # is *dangerous* <igli> (with the others too) <go|dfish> 'shush' ? * igli sees that go|dfish's medication has run out. <go|dfish> What the hell are you asking for opinions for if you're going to say that. <go|dfish> Shut up igli, you retard. <igli> yes dear ;) <igli> take a chill pill ffs <go|dfish> I don't have any. <go|dfish> He asks for advice, says shush when he gets advice. <igli> well go see your doctor again, and this time try not to hit him <go|dfish> Go away or i'll delete a factoid and you can /part again. <go|dfish> gladier: Asking for help, and replying with 'shush' will not get you help. <igli> wooh <go|dfish> You either want help, or you do not. <go|dfish> You shouldn't be a dick to people who offer help. <igli> while others /need/ help, but don't see it. ;) <gladier> want help - lacking the expletives <igli> read the urls given, for help on the basics <go|dfish> igli: If you are referring to me, go look in a mirror. <go|dfish> gladier: a lack of quotes and not checking cd, would be the initial thing i'd fix. <go|dfish> You can then clean up stuff, like the foo | grep | cut, the use of basename, etc. <igli> go|dfish: w/e you're still a bitch and will prob'y remain one till the day you die. kthxbye <igli> i suggest you try /ignore for a bit. god knows i had to ignore you for long enough <go|dfish> igli: I don't need to. <Gekz> lol * Gekz enjoys the bitchfight <igli> hehe <go|dfish> Ah Gekko, I like your hostmask :) <Gekz> lol <Gekz> danke. <igli> jeez talk about moodswings. ;) <kojiro> Mendel has decided not to take my advice about the contributed script on TLDP ABS guide. <kojiro> I guess it will stay broken. }}}

  • These two have a history of conflict. Not quite sure who was the "idiot" here, since I didn't post this one.

cptmorgan vs. greycat

{{{<cptmorgan> how would i have bash properly ls and grep just for file names to create a command with a input value for each file? <greycat> cptmorgan: Huh? for f in *; do mycommand "$f"; done <matteo> cptmorgan: find -print0 |xargs -0 <matteo> or for i in * <cptmorgan> matteo: thx you <cptmorgan> matteo: for i in INPUT-FILES/prom*; do find INPUT-FILES/ -name prom* -print0 | xargs -0; done <greycat> what the FUCK? <matteo> omfg <cptmorgan> matteo: whoops... <matteo> cptmorgan: use for OR find <greycat> cptmorgan: Just tell us what you want to do. We'll write the code. <cptmorgan> i was editing that and gonna erase things and hit enter by accident <lhunath> cptmorgan: there's so much wrong with that.. <matteo> for i in INPUT-FILES/prom*; do something $i; done <matteo> OR <lhunath> cptmorgan: use -exec, not -print0 | xargs -0 <matteo> find INPUT-FILES/ -name 'prom*' -print0 | xargs -0 something; done <matteo> btw <matteo> a BASH for is better <matteo> so trash find <cptmorgan> i basically have a script that sets a qsub job. that script runs a second script that has a variable for the input file and goes on to execute the command. i want to change this variable so it will look for a file(s) in a directory and run the script for each one <greycat> cptmorgan: so you want to run "foo" on every file in a directory, one at at time? for f in *; do foo "$f"; done <cptmorgan> greycat: i have a script that runs this inside it: /opt/torque/bin/qsub -l nodes=1:ppn=${N} pbs_mpich2.sh;done but then goes on to wait for the script to finish and times it. thing is in that second script i set a variable for the input file. i want to change this variable so that it will take a directory listing and run the problem for each one. so 2 commands need to be executed. <greycat> cptmorgan: ${N} is a filename? <greycat> I'm totally lost. <cptmorgan> greycat: INPUT-FILES/prom-??????-??????.tfa <greycat> I can't follow 75 conversations at once when one of them is all vague and hand-wavey and talks about variables that aren't shown. <cptmorgan> i will post my scripts <greycat> Why can't you just say what you want the script to DO? <greycat> Then we can tell you what commands to use. <cptmorgan> greycat: look at the JOBSIZEDESC variable in the second script. thats what i want to change to multiple files. http://pastebin.com/m7f72d1af <greycat> 132. <greycat> hundred thirty two lines!! * greycat whimpers and hits the left arrow lest he be sucked into the pit of despair <cptmorgan> greycat: 108 <flash42> yeah no fair to count in blanks <greycat> Like I'm going to COUNT them?! <greycat> The highest numbered line on the screen was 132. <cptmorgan> greycat: -p blastn -d human_g -i ${MB_INPUT} -o ${MB_OUTPUT}" how can i get that INPUT variable from a list of directories.? that better? <greycat> I don't see an INPUT variable there. <greycat> I see MB_INPUT and MB_OUTPUT <cptmorgan> MB_INPUT=input.${JOBSIZEDESC} <cptmorgan> its set to medium. so it grabs input.medium <greycat> for f in *; do blastn -d human_g -i "$f" -o "$f".output; done <greycat> I don't know how many fucking times I have to write it! <greycat> This is, what, 4 times you've been shown it now? <cptmorgan> greycat: i have to figure out a better way to explain this. ya your right but the first script has to run qsub for every one of those file too <greycat> Then do that. <cptmorgan> greycat: i got it! could i have a simple bash line that would create a new pbs_script and replace that INPUT variable? that way the first script could just start qsub pbs_scripts*.sh <greycat> cptmorgan: "I have _. I want to _." <greycat> For example, the first blank might be "7 *.frob files in one directory". <anonymouz666> hah <greycat> The second might be "run qsub -qbert <filename> and then blastn -i <output of qsub> for each file". <anonymouz666> that's what I call babysit <cptmorgan> greycat: exactly <greycat> for f in *; do qsub -qbert "$f" -output "$f".qsub; blastn -i "$f".qsub -o "$f".blasted; done <greycat> That's FOUR times I've told you "for f in *; do ...". And I'm pretty sure someone else had one also. <cptmorgan> greycat: THAT method will not work for what i have to do. <greycat> cptmorgan: *plonk*}}}

  • "You mean you want to do this?" "Exactly." "Well, then you do it like this...." "That won't work for what I have to do." ... That means you lied to me when you said my example was "exactly" right! Argh! Make up your mind!

x86 vs. greycat

{{{<x86> I'm trying to find files older than 30 days <greycat> !find > x86 ->#bash x86: http://wooledge.org/mywiki/UsingFind <felipe_> teh scrip command? <x86> so I do find /path -mtime 30 <savetheWorld> felipe_: "script" <x86> but I get nothing <greycat> x86: -30 not 30 <greycat> oops. <greycat> x86: +30 not 30 <x86> even if I do find /path -mtime 1 <x86> greycat: thanks <greycat> !find > x86 ->#bash x86: http://wooledge.org/mywiki/UsingFind <x86> now is ctime basically "create" time? <trash> no <savetheWorld> !ctime ->#bash ctime is NOT creation time! It's (metadata) change time. It's updated whenever a file's ownership, permissions, etc. change. Unix does not store creation time of a file ANYWHERE, at all. There is no way you can possibly know when a file was created, unless you're on a system with nonstandard file system extensions. <x86> greycat: seems if I do: "find /path -mtime +30 -exec rm {} \;" I get "missing argument to '-exec'" <greycat> x86: You did not get that error from that command. Try again. <trash> x86: what system are you on? <lhunath> ppc. <greycat> At least, you didn't get that error from that command in a Bourne family shell. <x86> ah, i was missing the \; ;) <x86> thanks guys <lhunath> eval "find /path -mtime +30 -exec rm {} \;" <- that might cause it.

...

<x86> say each line of a file contains a file name, some of which may have spaces <x86> it seems when I do "for x in cat ${file}", it makes the names with spaces into two distinct entries <greycat> !faq 1 > x86 ->#bash x86: http://wooledge.org/mywiki/BashFAQ/001 -- How can I read a file line-by-line? <greycat> !find > x86 ->#bash x86: http://wooledge.org/mywiki/UsingFind <x86> greybot: not using find this time ;) <greycat> It just *happens* to be *identical* to the output of find. <greycat> But you're not using find. <greycat> Right. <x86> greycat: I use find to generate the file, then I use a for loop to parse it <greycat> Don't. <x86> just telling you i'm not using find to do the second part ;) <x86> while read looks good <greycat> I'm just telling you you're a moron. <x86> greycat: becasue I didn't know how to do it better somehow I'm a moron? <x86> nice methodology <greycat> *plonk* <x86> really prognostic <greycat> It's not like I FAILED to give you all the relevant URLs as soon as you started asking the question. <x86> greycat: you gave me the correct URLs and I'm reading them * greycat guesses x86 was too busy regurgitating his crappy problem instead of reading the URLs provided. <x86> greycat: and I even mentioned I'll move to while read, like your URL said <x86> wow man nice attention span... <x86> you totally missed that I guess ;)}}}

  • Once again, there's a deeper problem that the person asking the question refuses to address. They've made a mistake already, and even when that mistake is pointed out, they refuse to step back and take a different path to avoid it. They demand that we tell them the next step which will somehow magically cancel out their original mistake. Extremely frustrating.

Idiot (last edited 2021-11-05 15:08:05 by emanuele6)