free blog   apache   shopping directory   php powered
koala_mansami: no, use -name '*TID*'
hyper_chm4n: :)
samikoala_man: ohh that easy
samikoala_man: That doesn't work as intended.
pgasm4n: well yes, I was just showing an example of empty argument, a better example in the context would have been -o '', though I have no idea where the problem is and if there is one
pgasargh too late
t3rm1n4lis there a bash commonly used recipe available ?
Fatalfor cake?
samikoala_man: nvm my bad
KiiKhow to answer it auto in ?
KiiKDo you want to ignore this warning and proceed anyway?
KiiKTo continue, enter "Yes"; to abort, enter "No":
koala_manecho Yes | theCommandThatAsks
Action: Superflaw|ay would use a here string
mum-n-dadAt - how do I incorporate the "retries" part with the now infinitely retrying "while ! git pull; do :; done" part?
Superflaw|ayit's #bash
pgasprobably something like && ((retries--)); do
mum-n-dadpgas: wow.. dude thank you so much
samiWhy wouldn't this work from within a script? TEST=`find * -maxdepth 1 -mtime +10 -name '*TID*' -exec ls {} \; | sed 's/"+TID+"//'`
pgasuse $( ) instead of ` `
samipgas: It still ignores the sed
hyper_chcould it be that a process is finished yet for some reasons the data is not written entirely to disk yet?
pgassami: probably not, set -x is your friend
Rivierasounds like you really should use wait
hyper_chwait doesn't work either
hyper_chtried it, same result
Rivieraokay, sorry for the wild guess :)
hyper_chRiviera: it's ok... I think the problem is between the finishing of the process and the actual writing of data to the harddisk
hyper_chsince I then hash data on the harddisk it's of no use if the process is finished but data is still getting dumped onto the disk
mum-n-dadpgas: yuu sure that works with zsh too?
mum-n-dadim sorry for asking a zsh question in here though - but the guys in #zsh are assholes
pgasno I'm not
pgasseems to work here though:
pgas% tries=2;while ! false && ((tries--));do echo tries;done
Last message repeated 1 time(s).
mum-n-dadyou are a lifesaver dude
hyper_chhmmm, is there a way that I can specify a directory and list all open files within that directory?
Bushmillshyper_ch: lsof should be helpful
Superflaw|aymaybe lsof ?
hyper_chBushmills: :)
Superflaw|ayI'm interested in the flags, if you find them all :p
zarckor fuser
hyper_chSuperflaw|ay: just read through lsof :)
Bushmillshyper_ch: it wasn't me
hyper_chdamn :( it just doesn't want to work :(
samiAs i understand it find -mtime +10 would be 10 days.
twkmmodulo granularity, yes.
mum-n-dadpgas: It keeps retrying infinitely it seems
pgasmum-n-dad: ah, well the retries test should come first
mum-n-dadyeah sorry about that trash
hyper_chI finally got it :)
Bushmills+d /path/dir works for me
Mohanwhat does '(:h)' this one do in the above pastie?
Mohanfor folder in $PWD/**/.git(:h); do
pgasask in #zsh
Mohanoh its not bash, I didn't notice it.
Bushmillssami, not quite.  it'd be 11 days, where 1 day ago means "at least 24h ago"
Bushmillsactually, +0 does not find files < 24 h
kbrandtWhat is the proper way to kill jobs all on a singal (and any children of those jobs?)
kbrandtOh nevermind, I have it I think, had an eval in there
samiBushmills: Ok
zxd_what does  set -e   do
zxd_I forgot
zxd_got it
heverHi. I'm checking the occourence of a string in stdin using a loop in a loop. It works but I think there are better solutions, do you have any suggestions?
realubotI got some help here beofre, but I didn't manage to get the code working using the tip so I'll ask you once again.
twkmhever: [[
Action: SuperFlo was thinking of something that ugly : egrep -q "(t1|t2)" && exit
pgashever: if would use awk...or maybe grep is enough?
heverits a variable amount of strings I'm checking...
hevertwkm, I use [[
Bushmillsyou could test for t[1,2]
twkmthen why do you need two loops?
realubotI have a text file conatining only one signel line that's very long. The line has got special characters that seperate some different parts of the line, like <seperator>. Then I want to "save" different parts of the line into different variables, like the text between first and second tag into var1 and the text between second and third tag into var2 and so on. After having like 6 variables I'll store the text between
pgashever: you can still use grep, with one pattern per line in a variable
heverBushmills, the Exeption will be some strings t1,2 are just examples.
Bushmillsso was my reply :D
realubotThis is what that the text file looks like: <tag>this is some text<tag>this is also some text<tag>this too<tag>
hevertwkm, because I've a variable amount of exeptions I'm going to check...
heverPerhaps this code is good enough....
pgasIFS=$'\n'; if grep -q "${array[*]}";then echo match;fi
realubotThen I want to create a variable contining the text between 1st and 2nd tag into var1 and the text between 2nd tag and 3rd tag into var2 and so on...
realubotAfter like tag 6 or 7 I will start over agian and create var1 out of the 7 to 8 tag, var2 out of the 8-9 tag etc.
lhunathif (IFS=$'\n'; grep -q ..)
heverwhats IFS?
SuperFlointernal field separator
realubotI'm looking for a way to grep the text between like the n:th and (n+1):th <tag>.
pgasrealubot: use an xml/html parser
realubotpgas: The tags are all the same, like <tag>, there is no special tags, just <tag> between the text parts of the line.
realubotpgas: Not <title>, <content> or something, just <tag>.
pgasrealubot: paste an example of your input
realubotIsn't it possible to like remove all but the text between tag n and n+1 using like sed, wehere I add n++ at the end of the loop, going through the loop over and over agian?
sn18realubot: read it into array?
heverlhunath, that does not work ;)
realubotpgas: Well, it looks like this: <tag>Some kind of text<tag>more text<tag>hey ho let's go<tag>one more text string<tag>
realubotpgas: It's one single line and I get it from zenity --list --editable --column1="Title"...
pgas# arr=( foo bar baz); echo foo | if ( IFS=$'\n';grep -q "${arr[*]}");then echo hever: works here ;fi
evalbotpgas: hever: works here
realubotZenity outputs all in a editable list by having the --separator="<tag>" to put <tag> between the content of each column. I can't set speciela seperators for each tag.
pgasrealubot: you can perhaps use something like awk -F '<[^>]*>' '{print $2}'
lhunathhever: that "works" just fine, and I was merely improving upon pgas' suggestion; not sure what it is *you* are after exactly.
heveraah you have to pipe it to if ...
pgashever: well not really, grep reads from stdin
pgasecho foo | was just a way to write something on stdin
lhunath!io > hever
greybothever: Data and File Processing:
realubotpgas: Yeah, I'm not that familiar in using awk. Maybe I can use something like sed 's/<tag>/ \n /g' > input.txt then loop every line using while read line; do echo "$line" done < input.txt
twkmi suggest not using bash, and write the entire thing in awk or perl or ruby or ...
realubottwkm: It will take me too much time cause I'm not used to Perl or Ruby.
pgashever: what is your script supposed to do? print all the lines up to the one matching one of the pattern?
realubotWhy do you not suggest using bash to parse text between tags? I mean, bah is very powerfull and will somehow manage to do this kind of job, am I wrong?
heverthis example yes, the realone is an email log reporter
pgasrealubot: yes, but it's not made for this kind of job, the result will be slow and it will involve more works
pgashever: well, I would write an awk script
realubotpgas: Ok.
pgasor perl or ...
heverjust use the two loops ;)
pgaswhat I've just said to realubot applies to you too
JoshDreamlandHi, is there a way to move the contents of all the directories in a directory to a new directory, without moving the directory names themselves?
JoshDreamlandFor example, a/ contains folder b/ and c/. A separate folder, d/, is elsewhere. Can I move a/b/* and a/c/* to d/ without moving b/ and c/ and without knowing their names?
JoshDreamlandCopying is fine, rather.  Not necessarily move.
JoshDreamlandI just need a copy of the contents of all subfolders to be moved to a new folder.
spixx|workcp -r ?
spixx|workcp -r /folder/with/subfolders/
sn18JoshDreamland: using find or globstar in bash 4
JoshDreamlandsn18: then piping their output to cp?
Titan8990JoshDreamland: possibly: find /path -type f -exec bash -c 'cp "$1" newdir/' -- '{}' \;
JoshDreamlandTitan8990: Thanks, I'll give that one a try
JoshDreamlandTitan8990: Worked great. Thanks much!
Titan8990JoshDreamland: np
pgasif you use \; you can do -exec cp -- {} newdir \;
Stalafinhey! i have a question about the printf command: if i want to print the vars FOO and BAR, would printf "%s\t%s" ${FOO} ${BAR} work? or is there something wrong with my syntax?
twkmi would quote the parameter expansions, otherwise it seems fine.
tjgHi, hopefully you can help me... I have a bash script where I launch a daemon in the background, then get its PID using $!. But when I launch it with a different user (su --command "<cmd> &" <user>), I don't know how to get the PID. How should I approach this?
Stalafintwkm: quote the parameter expansion?
Stalafintwkm: as in "${FOO}" ?
zimmermanc# cat "${FOO}"
evalbotzimmermanc: cat: : No such file or directory
FatalStalafin: "$FOO" works fine (${FOO} == $FOO, "${FOO}" == "$FOO", the {} adds nothing)
tjgHmm, I'm thinking I can put the command in its own bash script, which I call with a different user... And within that script, write $! to a file, so my outer script can find it.
pgasthat or sh -c 'cmd & echo $!'
SuperFlotjg: that's usually what daemons do, they have a pid file
tjgpgas: Ah cool, I'll try that out!
mum-n-dadpgas: is this: while ! git pull && sleep 5 && ((retries--)); do :; done
mum-n-dadthe same as: git pull && break || sleep 5?
mum-n-dadi mean which would be preferred..
tjgSuperFlo: Yeah... This shell script (I didn't write it) is in /etc/init.d, and then writes the pid file after launching the command in the background... I'm not a sophisticated bash programmer, so I have no idea whether this is good form.
DrMax_is there a way, within a script, to determine if the script was launched from the prompt or "source"d ?
mum-n-dadAt - will "while ! git pull; do break; done" stop the script if "git pull" fails, or will the loop keep on running?
KnihtDrMax_: I think you want
mum-n-dadI.e. I get "fatal: The remote end hung up unexpectedly"
KnihtDrMax_: if you figure out what you asked, though, I could use that too :)
DrMax_Kniht : I have a... let's call that a legacy script... that expects to be sourced rather than invoked directly
DrMax_except that I do not have the invoker
Knihtmum-n-dad: 'break' exits from the while loop, 'break 2' would exit the for loop, 'exit' will exit the script
noescI would need some help in parsing a file. I've got a shitload of files ~6,5k where ALOT of them are duplicates (with different filenames), and I want to remove all duplicates. I've calculated md5sums for all files and saved to a normal textfile. How would I continue from here?
pgasuse an already existing script?
DrMax_sn18 : it's undefined unless from a script ?
DrMax_hmm ok let's try this
pgasDrMax_: is it supposed to be sourced from a login shell? or from another script?
pgasnoesc: shelldorado has such a script, there is an "fdupes" out there
mum-n-dadpgas: is while ! git pull && ((5)); do the same as doing retries=5 and then while ! git pull && ((retries--)); do?
noescpgas, I'll check it
DrMax_pgas : the intended use is probably to be sourced from another script, which doesn't exist anymore. You have to invoke source for it to work properly
DrMax_which is cumbersome
sn18mum-n-dad: no
pgasDrMax_: so you source it from another script?
DrMax_or fix the source-dependent parts
mum-n-dadsn18: How do I do it then?
DrMax_hmm ok
pgas? oh well..
mum-n-dadpgas: Could you give me a hand?
ebiDoes anyone know how to get bash completion for the history search commands like !:tab tab
mum-n-dadpgas: At - this script should: if "git pull" fails, retry it 5 times (but sleep 5 seconds prior to each attempt) - and if that too fails, stop the whole script. Am I doing it right?
andy_t_roodoes command || exit 1; terminate the script if command fails?
sn18mum-n-dad: while loop will continue till git pull succeeds
mum-n-dadandy_t_roo: I don't know, I'm using command || break;
sn18mum-n-dad: you dont need || break
mum-n-dadsn18: I only want it to run 5 times
mum-n-dadsn18: Is that possible?
sn18mum-n-dad: retries=5 ;  while ! git pull && ((retries--)); do
mum-n-dadsn18: I must have retries=5?
mum-n-dadthere's no way around that?
Bushmillsno. you can also have 10
Bushmillsthen you'd do  ((retries-=2))
mum-n-dadWhat I mean is, do I really need that variable thing
mum-n-dadcan't i just incorporate the 5 retries in the while loop itself?
Bushmillsfor i in {1..5}; do ... ; done
mum-n-dadok ill keep the variable thing :)
sn18sleep 5 && :
Popular searches: shp2osm jar mac   linux arping indefinitely   fluxbox mouse no hourglass   pidgin 2   

Generated by 2.1mg by Jeff Waugh - return