| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9
Comments:
<0> as they can be nested? <1> Netfeed: yes. <0> ah, cool, thanks <1> Narada: having no examples of the odd script names you use i cannot be sure, but i see no particular reason for the expansion i provide to fail. <1> $ var="/arbitrary/foo bar baz/script" ; echo $(dirname "$var" | cut -d' ' -f2) ; var=${var%/*} ; var=${var#* } var=${var%% *} ; echo ${var%% *} <1> bar <2> foo ? <3> mitzvah! <2> ! <2> night * <1> of course since you do ''dirname $0'' you obviously don't have whitespace in your $0 path, so why the cut i do not know. <4> twkm: strange; i did that because when testing the output was "dirname a/b/c" that's why i did the cut; but i can't reproduce it; obviously i read it wrong <4> twkm: basically what i wanted to do was (1) not to have any hardcoded paths in the script at all) (2) the script could be called from anywhere and it would know where it was and know the two locations it should act upon <1> Narada: given an input of /a/b/c i take it you want just /a/b as output? if so then the first expansion is sufficient. <1> Narada: how about not having a THIS_DIR at all? just work with . or $PWD?
<4> $PWD keeps changing depending on where the script is invoked <4> i cannot have relative locations like $THIS_DIR/../../ relative to $PWD <3> what is your goal? <4> okay i can try to explain further what i am doing in case it is not clear <4> okay i will explain <3> oh, I see... about 3 minutes ago. <3> !faq location <5> 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. <3> What you want is Completely Impossible. <4> :( <4> But I've already implemented it. <4> In that link I pasted. <4> It works but I was just wondering if it could be made any more concise and efficient. <3> in the general case, on Unix (as opposed to Plan 9), it is IMPOSSIBLE to resolve a symlink mess to absolute paths. <4> So readlink() is the problem in my script? <3> even resolving something as "simple" as ../bin is ambiguous. <4> That link you gave me is unresponsive. <3> works for me. <1> heh. <4> Okay finally loaded. Took ages. Must be office connection. <4> I can't believe something so straightforward would not be possible. <1> speaking of which, someone needs to poke the local access providers to get ftth deployed. <1> Narada: why is . inappropriate? <4> I am not using symlinks in those locations and I do not need the script to be portable just to work on a couple of modern systems. <3> it's those "modern" systems with their newfangled symbolic links that are the problem. <4> twkm: Sorry I don't understand your question <4> oh right <4> does that resolve to the pwd? <1> Narada: how is it that you cannot use THIS_DIR=. ? <1> Narada: is the script in some other directory than the current one? <4> okay i have an svn checkout in /home/narada/web/trunk and the script is in /home/narada/web/trunk/bin/svn-update.sh so i want to be able to invoke the script from anywhere and it will only act on SCRIPT_LOCATION/../ and SCRIPT_LOCATION/../cache/* <4> so because i am doing things like ../ if i rely on pwd or . the bit before ../ keeps changing depending on where you are and where you are invoking from right? <1> ahh, so it is supposed to affect just one directory? why don't you put it in the script? <4> you mean the full absolute path in a script variable <4> i was trying to prevent hardcoding any paths in case the directory names are different for each person <4> the hierarchy is the same within the svn checkout but the absolute paths to the checkout are different <4> well it affects two directories: SCRIPT/../ and SCRIPT/../cache/* <1> well, good luck with it. <4> heh thanks <4> i've no doubt that my explanation of the task was not understood in the slightest but that's okay <1> it seems clear enough. <4> so you understand why i can't put it in the script <1> did greycat's mention of symlinks not make you worry? <4> yeah but i was simply conversing with you in response to what you were saying <1> nope. i put paths into scripts all the time. part of change management requires that i make a note of that, so that if the directory path is changed i would know to edit the script too. <4> if it's impossible it's impossible just let me know <4> yeah okay i'll see if i can put it in the script <4> there's reasons why that might be a problem but if that's the only way that's the way it has to be <1> nobody said it was impossible. it is merely risky. did you read the faq entry? <4> some of it; i'll read the rest now; like i said also i'll try to put whole path in script <1> anyway, happy hunting. i need some sleep. <4> k thanks for your input anyway <6> Any way to find out if a file is a subset of another file? <3> !faqsubtract <5> http://wooledge.org/mywiki/BashFaq#faq36 -- How can I get all lines that are: in both of two files (set intersection) or in only one of two files (set subtraction). <6> greycat: File not in the line sense but as a block <6> Alle lines from file B should appear in file A in the same order <3> ... what? <6> I don't want all the lines from file A that aren't in B or something like that <3> uh... get the byte count (size) of file A. dd that many bytes from B into a temp file T. diff A and T.
<6> urg ... the block of lines could be somewhere in B <6> but throwing dd and diff at me could be a hint that it will be hard <7> like grep, only for a pattern spanning multiple lines <3> then you need something a lot more sophisticated than a stupid little bash script. <3> if diff(1) can't do it, crack open some computer science algorithm books and start coding in C. <6> greycat: Okay, thanks then <7> it's just a substring search, with lines instead of characters <8> couldn't you do also something like: [[ $(<a) =~ $(<b) ]] && echo ok (if the files aren't too large) <3> x_: nope. $(<foo) strips trailing newlines, for starters.... <3> and I'm not at all clear on how they handle NULs. <9> cmp <9> compares files bytewise <10> hey guys, i tried to apply one of my old patches to a new distro... most of it succeded, but some failed. what do i do with the .rej files ? <3> how is this bash related...? <10> well the patch utility .. <3> read them. apply them by hand. with a text editor. <10> why do they fail though? (here's a shor example http://pastebin.ca/123653) <3> why do we CARE? <10> :( <11> Hi! Is it possible to emulate the following behaviour under bash: <11> If I've previously issued a bunch of commands: vim test, ssh foo, vim bar <11> if i press s and the up arrow it scrolls through the history, but only shows commands ive previouslyissued starting with <11> the letter s <12> try ctrl-r <12> it's close, maybe not what you want <11> yes, i do that now .. but it's not quite what i want <11> :) <11> thought that since the functionality is partly there ... <12> nobb, if you look at set | less, you will see functions handling completions and history, afaik. You could patch them <12> And read the "HISTORY" and "HISTORY EXPANSION" sections of the Bash man page <12> apart from that, perhaps somebody else here knows a quicker solution <13> Hi, how I can do 2 for cicles one into another?! <11> locsmif: ill look into that <13> for p in <13> $(for i in $(ls /raid/vpopmail/domains) <13> do <13> cd /raid/vpopmail/domains/$i && cat vp***wd | awk -F: "{print \$1\"@$i \"}" <13> done); do /appoggio/vpopmail-5.2.1/vuserinfo -q $p; done <13> Not like this I think.. <12> danielinu, <12> for X in ...; do <12> for Y in ...; do <12> ... <12> done <12> done <13> it will take the first output to process the second command?! <12> danielinu, you're better off using while read then <3> for i in $(ls....) is almost always a bad idea. <12> yes, use find <13> can you give me an example?! <12> greycat, is there a FAQ entry? <12> !faq while read <5> No matches found at http://wooledge.org/mywiki/BashFaq <13> I have to exactr user@domain p***word and quota from some dirs and commands :( <3> !pitfalls <5> http://wooledge.org/mywiki/BashPitfalls <14> I have a collection of files, all in similar format - they all contain the same lines (section comments) as delimiters between sections of vaguely the same size. I'd like to pad the space to the next comment with newlines so that in all files, the section comments are on the same line in all files. Could anybody give me a rough indication in what direction to look? <15> I'm trying to spawn a script in its own process, and redirecting that script's output to a file. <15> ./foo 1>out.log 2>&1 prints to the log file, but doesn't spawn its own process. <15> ./foo 1>out.log 2>&1 & spawns its own process, but doesn't print to the log file <15> What am I missing? <16> help '{' <3> catfish, it's probably getting killed when your script ends. <15> the log file is getting killed? <15> Ahh, the piping into a log file only occurs once the script has finished executing? <15> Hmm. Is there a way to get continuous output? <10> can i make a patch that can rename a file through `patch` ? <3> only by deleting all the lines from one file and creating a new file with all those lines.... <10> oddly enough it didn't create the new file either though <10> you sure it can make new files? <3> of course it can. <17> yo jax.. <17> greycat <3 <17> tail -F ~/.x11vnc.log | grep 'Got connection' | while read msg ; do Xdialog --msgbox "$msg" 0 0 ; done
Return to
#bash or Go to some related
logs:
java-void(0) emacs vim bindings howto is cherrypy secure myanmarlovestories #debian ioctl[SIOCSIWPMKSA]: Operation not supported ubuntu ipw css21 chm #perl ntfs-captive+ubuntu kdetv xgl problems
|
|