« first day (1293 days earlier)      last day (3674 days later) » 

8:01 PM
@terdon Thanks...
 
Not sure what exactly is going on but it's the single quotes that are causing it.
 
But when I just use the first expresstion (force_color_prompt) it works
 
@Aditya That's the only one that has no quotes in it
Hmm, no, I'm wrong. That's not the problem
AAH! Got it!
@Aditya, the problem is the spaces. Since you have not quoted the expressions, sed takes the first space to be the end of the expression and complains because you didn't close the s/// operator:
$ sed -i.bak -e s/a b/ab/ .bashrc
sed: -e expression #1, char 3: unterminated `s' command
$ sed -i.bak -e s/a\ b/ab/ .bashrc
$
 
But isn't spaces part of the regex?
 
So escaping the space is enough. That's one of the reasons why you should always quote your sed commands
 
8:06 PM
@Aditya this worked:
sed -i.bak -e 's/#force_color_prompt=yes/force_color_prompt=yes/' \
-e "s/#alias dir='dir --color=auto'/alias dir='dir --color=auto'/" \
-e "s/#alias vdir='vdir --color=auto'/alias vdir='vdir --color=auto'/" \
~/.bashrc
 
@Aditya Yes, but because you're not quoting, the shell passes only s/a to sed as the first argument
 
@Braiam yes
 
Remember that sed is called by the shell and it is the shell that will pass it the arguments you give
 
@terdon ah
 
Since you're not quoting, the shell sees -e s/a as the first argument (well, -e as the first and s/a as the second)
and b/ab/ as the second
 
8:07 PM
@Aditya if you are not sure what you need you can use echo before the command
 
that makes sense
@Braiam example
 
@Braiam echo?
echo won't split on IFS, everything is passed as a block to it
 
@terdon quoting like s/"aksf sldakf "/"asdlkf jlas;dfsd'af"/ also works
 
@Aditya Yes, anything that will join the spaces will work. But don't do that.
Just always quote your sed expressions.
 
@terdon because quotes become part of regex?
 
8:10 PM
@Aditya Mostly because they protect your regexes from being interpreted/split or otherwise screwed with by the shell
 
➜  ~  echo sed -i.bak -e 's/#force_color_prompt=yes/force_color_prompt=yes/' \
> -e "s/#alias dir='dir --color=auto'/alias dir='dir --color=auto'/" \
> -e "s/#alias vdir='vdir --color=auto'/alias vdir='vdir --color=auto'/" \
sed -i.bak -e s/#force_color_prompt=yes/force_color_prompt=yes/ -e s/#alias dir='dir --color=auto'/alias dir='dir --color=auto'/ -e s/#alias vdir='vdir --color=auto'/alias vdir='vdir --color=auto'/
@terdon ^
 
ANd because you should always quote. 99% of the time. There are various problems that it protects you from.
 
it shown what is being interpreted
 
@Braiam No. Try it, you get the same thing if you quote:
sed -e s/#force_color_prompt=yes/force_color_prompt=yes/ -e s/#alias dir=dir --color=auto/alias dir=dir --color=auto/ -e s/#alias vdir=vdir --color=auto/alias vdir=vdir --color=auto/ .bashrc
 
@terdon mine has the internal quotes ;)
 
8:12 PM
Because echo does not split its arguments, it prints everything passed to it.
@Braiam I know and without them you'll get exactly the same result
Because echo does not show this problem
Try: echo a b c d
and: echo "a b c d"
same output
But not at all the same situation. In the first case, echo gets 4 arguments and in the second 1. That is the problem here but echo won't show it because it simply prints its entire argv array.
 
@Braiam doesn't work for me
 
@terdon I see that yours doesn't have the ' in color, while mine does
aditya would have found that the quotes were eaten by the shell with echo
 
@Braiam Why? Do you get a different output when you do echo "a b c d" or echo a b c d?
@Braiam Yes, it works for the quotes but that was not the issue here, it was the spaces giving the error.
 
@Braiam running that command didn't return any output, neither sed did its work...
 
@terdon "spaces"? there wasn't any spaces issues
 
8:17 PM
@Braiam Yes, the only issue was spaces :)
 
@Aditya run this"
 
@terdon yes @Braiam
 
sed -i.bak -e 's/#force_color_prompt=yes/force_color_prompt=yes/' \
-e "s/#alias dir='dir --color=auto'/alias dir='dir --color=auto'/" \
-e "s/#alias vdir='vdir --color=auto'/alias vdir='vdir --color=auto'/" \
~/.bashrc
The only change is that I added the quotes from your original @Aditya
 
@Braiam This works... this is what terdon has suggested (your first suggestion was also this one) :)
 
However, the reason it works is because the quotes are protecting the spaces so bash is not splitting on $IFS there
 
8:19 PM
@terdon what is $IFS
 
It's the internal field separator, bash (and zsh I think) will split input according to that. Normally it is set to \n \t and space
 
oh...
 
To illustrate:
Hmm, hang on need to find a way:)
Here we go:
$ echo -e "aXbXc"  | while read var1 var2 var3; do echo "var1 is $var1, var2 is $var2 and var3 is $var3"; done
var1 is aXbXc, var2 is  and var3 is
echo -e "aXbXc"  | while IFS="X" read var1 var2 var3; do echo "var1 is $var1, var2 is $var2 and var3 is $var3"; done
var1 is a, var2 is b and var3 is c
 
this is what bash was sending to sed:
execve("/bin/sed", ["sed", "-e", "s/#force_color_prompt=yes/force_"..., "-e", "s/#alias", "dir=dir --color=auto/alias", "dir=dir --color=auto/", "-e", "s/#alias", "vdir=vdir --color=auto/alias", "vdir=vdir --color=auto/", "/home/braiam/.bashrc"], [/* 56 vars */]) = 0
 
@Braiam Exactly, look at the second -e
It is splitting on the space and sending "s/#alias" separately from "dir=dir --color=auto/alias"
 
8:25 PM
@terdon nice example.. :)
 
when I use the quotes or escape the spaces, this is what is being send:
 
@Braiam how did you get that?
 
execve("/bin/sed", ["sed", "-i.bak", "-e", "s/#force_color_prompt=yes/force_"..., "-e", "s/#alias dir='dir --color=auto'/"..., "-e", "s/#alias vdir='vdir --color=auto"..., "/home/braiam/.bashrc"], [/* 56 vars */]) = 0
@Aditya using strace before the command
as can be seen, it doesn't break in alias dir nor alias vdir
 
@Braiam Exactly.
 
@Braiam That is handy... thanks
I knew about strace, didn't know how to use it... Now I know what execve means... :)
 
8:29 PM
@Aditya by the way, in general echo is often useful, as Braiam suggested, for this kind of thing. It just won't show space issues because it outputs everything you pass it.
 
\o/
 
the problem with echo is that it wouldn't make evident the problem, I would know that if there's spaces between regexes and there isn't some character escaping it, it will give problems later
@dotbitcode none of the html code works here
 
@Braiam yeah noticed that :)
Did anyone ever (publicly) benchmarked any Stack Exchange site so far?
I'm trying to do that but results are clearly corrupted
this is what I get so far
Benchmarking 198.252.206.24 (be patient).....done


Server Software:
Server Hostname:        198.252.206.24
Server Port:            80

Document Path:          /
Document Length:        3885 bytes

Concurrency Level:      5
Time taken for tests:   1.857 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Non-2xx responses:      10
Total transferred:      39890 bytes
HTML transferred:       38850 bytes
Requests per second:    5.38 [#/sec] (mean)
Time per request:       928.537 [ms] (mean)
 
Things we learned today: 1. #stackoverflow runs okay on 2 web servers 2. Lack of L1 cache can take out all but 2 of our web servers
^ that speaks of itself
@dotbitcode I would ask in Meta Stack Overflow instead
 
@Braiam I see that. But numbers would speak even more. Well, that's a good suggestion, I'll do it right now.
 
8:41 PM
Another sed problem, trying to add a line as /opt/vnstat_switcher.sh to /etc/rc.local file before "exit 0"... I have created a copy of /etc/rc.local as ~/Desktop/rc.local
sed -i.bak -e "s/\nexit 0/\n\/opt\/vnstat_switcher.sh\nexit 0/" ~/Desktop/rc.local
It doesn't add the lines
 
@Aditya use awk
sed is bad dealing with newlines
 
@Braiam sed won't work?
Okay... would read the manpages, and try
 
@Aditya apparently you can sed 's/.*exit\ 0.*/\/opt\/vnstat_switcher\.sh\n&/'
with awk it would be awk '/exit\ 0/{print "/opt/vnstat_switcher.sh"}1'
 
I didn't understand any of the regex in commands :P
.*exit --> how does that match newlines
You are espacing spaces as well --> needed?
0.* --> what does that do
 
is not .*exit and 0.* but .* + exit 0 + .*
 
8:49 PM
switcher\.sh --> escaping ".", why
@Braiam Here "." is not a special character it is just "dot". For it to be any character we need to use it as [.]*
 
@Aditya they are called greedy operators
 
What's the difference between .* and [.]*
 
@Aditya in the first, the dot match any character, in the later it match the literal dot
because [] means to match any character in the range/set
@Aditya this could provide more detailed explanations in real time regexr.com and if you need the references regular-expressions.info/repeat.html
 
@Braiam sorry... had power outage for a couple of minutes..
 
9:01 PM
@Aditya Strange, we had a power outage here too o_O I live in central Europe..
 
@dotbitcode haha..
 
meh, I have power outage for couple of minutes to several hours and I am sure that it will be coincidence if anyone else does
 
Sigh!
http://askubuntu.com/questions/447810/ssh-connection-refusal-unable-to-ping
 
@Aditya @Braiam Yeah but here it doesn't happen so often ;)
Anyway, posted the question to StackOverflow Meta let's see what we find out :P
:)
0
Q: Was any Stack Exchange site ever publicly benchmarked?

dotbitcodeHas anyone, or was any Stack Exchange site ever publicly benchmarked? This curiosity came to me because I'm building a site similar to this and needed an already existing site as a model, to compare the benchmarks with my site's own. I've tried nearly everything so far, but the results are far ...

 
@Braiam I had the inverse idea about matching dots..
 
9:05 PM
@Braiam hehe nice one :P
 
0
Q: The preformatted text/code text font in chat is not sufficiently distinct

searchfgold6789In chat, when putting text between grave accents to ensure that it is output as code, the resulting text is not very distinguishable from the other text: The only way it's different, right now, is that a different font is used. Is there any way we could highlight it make it a different col...

 
@AzkerM I'm not sure how is that related to Ubuntu
 
@Braiam Indeed! But I was trying to support him assuming he may be using an Ubuntu distro. But he at the end said that its a windows system. Sigh :/
 
@Braiam That doesn't work... `/etc/rc.local' has "exit 0" in its comments as well - hence the need to match new lines before "exit 0"...
 
ohh, you need to match the last one
 
9:15 PM
@Braiam What would you suggest on the link that I've posted here. I mean if its not fitting Ubuntu?
 
if he asks the same question on either SU or UL it would have be closed as unclear
 
Indeed! But I manage to get him onto a certain point. Nevertheless, he's clueless on what he's doing.
 
@Aditya I know awk could help, but I'm not able to find the important bits, this should be an start stackoverflow.com/a/21331961/792066
 
How do we past the question here as seen above instead of link been displayed?
 
9:40 PM
@AzkerM not sure what you want
 
10:00 PM
@AzkerM Post only the link on a single line by itself. Then it will onebox.
please use oneboxes sparingly.
 
 
1 hour later…
11:16 PM
(posted in the Regulators room instead)
 

« first day (1293 days earlier)      last day (3674 days later) »