Rack requests files non stop - heroku

I create a simple rack application to serve static files on heroku. But I have a problem that when trying to run the application locally with rackup. It seems to requests files continuously, this results hanging tab in Chrome.
What is the problem I have and how to fix it ?
config.ru
use Rack::Static,
:urls => ["/images", "/scripts", "/styles", "/components"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
And the error :
...
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /scripts/scripts.js?_=1362996702033 HTTP/1.1" 200 8543 0.0007
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/jquery/jquery.min.js?_=1362996702034 HTTP/1.1" 200 92629 0.0021
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/jquery-ui/ui/minified/jquery-ui.custom.min.js?_=1362996702035 HTTP/1.1" 200 228147 0.0041
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/angular-strap/dist/angular-strap.min.js?_=1362996702040 HTTP/1.1" 200 11632 0.0010
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/bootstrap/docs/assets/js/bootstrap.min.js?_=1362996702041 HTTP/1.1" 200 28545 0.0010
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/angular-ui/build/angular-ui.min.js?_=1362996702042 HTTP/1.1" 200 17515 0.0009
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/angular-ui/build/angular-ui-ieshiv.min.js?_=1362996702043 HTTP/1.1" 200 1018 0.0006
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /scripts/scripts.js?_=1362996702044 HTTP/1.1" 200 8543 0.0007
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/jquery/jquery.min.js?_=1362996702045 HTTP/1.1" 200 92629 0.0021
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/jquery-ui/ui/minified/jquery-ui.custom.min.js?_=1362996702046 HTTP/1.1" 200 228147 0.0041
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/angular-strap/dist/angular-strap.min.js?_=1362996702051 HTTP/1.1" 200 11632 0.0007
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/bootstrap/docs/assets/js/bootstrap.min.js?_=1362996702052 HTTP/1.1" 200 28545 0.0060
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/angular-ui/build/angular-ui.min.js?_=1362996702053 HTTP/1.1" 200 17515 0.0008
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /components/angular-ui/build/angular-ui-ieshiv.min.js?_=1362996702054 HTTP/1.1" 200 1018 0.0006
127.0.0.1 - - [11/Mar/2013 11:11:43] "GET /scripts/scripts.js?_=1362996702055 HTTP/1.1" 200 8543 0.0007
...

Related

Can't find catalina.out in OS X 10.11.3 inside apache-tomcat-8.0.33

I've just installed apache-tomcat-8.0.33 , I am deploying an application that has errors but I can't see catalina.out inside
/usr/local/apache-tomcat-8.0.33/logs
I only find this file localhost_access_log.2016-04-19.txt with this content:
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:10:31 +0200] "GET /manager/ HTTP/1.1" 302 -
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:10:32 +0200] "GET /manager/html HTTP/1.1" 401 2473
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:10:33 +0200] "GET /manager/html HTTP/1.1" 200 17910
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:10:33 +0200] "GET /manager/images/asf-logo.gif HTTP/1.1" 200 7279
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:10:33 +0200] "GET /manager/images/tomcat.gif HTTP/1.1" 200 2066
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:10:33 +0200] "GET /favicon.ico HTTP/1.1" 200 21630
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:07 +0200] "GET /manager/html HTTP/1.1" 200 16678
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:07 +0200] "GET /manager/images/asf-logo.gif HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:07 +0200] "GET /manager/images/tomcat.gif HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:07 +0200] "GET /favicon.ico HTTP/1.1" 200 21630
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:10 +0200] "GET /manager/html HTTP/1.1" 200 16678
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:10 +0200] "GET /manager/images/tomcat.gif HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:10 +0200] "GET /manager/images/asf-logo.gif HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:10 +0200] "GET /favicon.ico HTTP/1.1" 200 21630
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:23 +0200] "GET /manager/html HTTP/1.1" 200 16678
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:23 +0200] "GET /manager/images/tomcat.gif HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:11:23 +0200] "GET /manager/images/asf-logo.gif HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:23 +0200] "GET /favicon.ico HTTP/1.1" 200 21630
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:29 +0200] "GET / HTTP/1.1" 200 11250
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:29 +0200] "GET /tomcat.css HTTP/1.1" 200 5576
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:29 +0200] "GET /tomcat.png HTTP/1.1" 200 5103
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:29 +0200] "GET /bg-nav.png HTTP/1.1" 200 1401
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:29 +0200] "GET /bg-upper.png HTTP/1.1" 200 3103
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:29 +0200] "GET /asf-logo.png HTTP/1.1" 200 17811
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:29 +0200] "GET /bg-button.png HTTP/1.1" 200 713
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:11:29 +0200] "GET /bg-middle.png HTTP/1.1" 200 1918
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:12:51 +0200] "POST /manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=087B57A87D6F7602AA424197072B81EB HTTP/1.1" 200 17949
127.0.0.1 - - [19/Apr/2016:20:16:30 +0200] "GET /ideefe-iot-web/api/login HTTP/1.1" 404 1052
127.0.0.1 - - [19/Apr/2016:20:16:30 +0200] "GET /ideefe-iot-web/api/login HTTP/1.1" 404 1052
127.0.0.1 - - [19/Apr/2016:20:16:30 +0200] "GET /ideefe-iot-web/api/application HTTP/1.1" 404 1064
127.0.0.1 - - [19/Apr/2016:20:16:30 +0200] "POST /ideefe-iot-web/api/device HTTP/1.1" 404 1054
127.0.0.1 - - [19/Apr/2016:20:16:30 +0200] "POST /ideefe-iot-web/api/device HTTP/1.1" 404 1054
127.0.0.1 - - [19/Apr/2016:20:16:30 +0200] "POST /ideefe-iot-web/api/device HTTP/1.1" 404 1054
127.0.0.1 - - [19/Apr/2016:20:16:30 +0200] "POST /ideefe-iot-web/api/login HTTP/1.1" 404 1052
127.0.0.1 - - [19/Apr/2016:20:16:30 +0200] "POST /ideefe-iot-web/api/sigfoxCallback HTTP/1.1" 404 1070
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:27:19 +0200] "POST /manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=087B57A87D6F7602AA424197072B81EB HTTP/1.1" 403 3195
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:27:19 +0200] "GET /favicon.ico HTTP/1.1" 200 21630
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:27:22 +0200] "GET /manager/ HTTP/1.1" 302 -
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:27:23 +0200] "GET /manager/html HTTP/1.1" 200 17949
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:27:25 +0200] "POST /manager/html/undeploy?path=/ideefe%2Diot%2Dweb%2D1%2E1%2E0&org.apache.catalina.filters.CSRF_NONCE=B1046CB8EA35C96D335BAAD0D8CD3EF0 HTTP/1.1" 200 16752
0:0:0:0:0:0:0:1 - admin [19/Apr/2016:20:27:33 +0200] "POST /manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=75AFADA2F0CAD99F17D46E3370FCF5BD HTTP/1.1" 200 17949
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:35:13 +0200] "GET /examples/ HTTP/1.1" 200 1126
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:35:16 +0200] "GET /examples/servlets HTTP/1.1" 302 -
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:35:16 +0200] "GET /examples/servlets/ HTTP/1.1" 200 6645
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:35:16 +0200] "GET /examples/servlets/images/execute.gif HTTP/1.1" 200 1242
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:35:16 +0200] "GET /examples/servlets/images/return.gif HTTP/1.1" 200 1231
0:0:0:0:0:0:0:1 - - [19/Apr/2016:20:35:16 +0200] "GET /examples/servlets/images/code.gif HTTP/1.1" 200 292
i think you have not configured the path for the CATALINA_HOME.
Before starting you need to show the program where your CATALINA is suing environment variable

Webapp on Tomcat not responding

I have a installed Tomcat7 on my Windows Server. And I have a war-file to deploy Java application with REST to my Tomcat. I have no problems to go to Application Manager and to deploy my app. But I have a problem to get response from that app. Previously it was install on another Tomcat server and it worked fine. I looked inside logs and found only this
10.10.1.32 - - [23/Feb/2016:12:40:42 +0200] "GET / HTTP/1.1" 200 11418
10.10.1.32 - - [23/Feb/2016:12:40:45 +0200] "GET / HTTP/1.1" 200 11418
10.10.1.32 - - [23/Feb/2016:12:40:45 +0200] "GET /tomcat.css HTTP/1.1" 200 5926
10.10.1.32 - - [23/Feb/2016:12:40:45 +0200] "GET /tomcat.png HTTP/1.1" 200 5103
10.10.1.32 - - [23/Feb/2016:12:40:45 +0200] "GET /bg-middle.png HTTP/1.1" 200 1918
10.10.1.32 - - [23/Feb/2016:12:40:45 +0200] "GET /bg-nav.png HTTP/1.1" 200 1401
10.10.1.32 - - [23/Feb/2016:12:40:45 +0200] "GET /bg-button.png HTTP/1.1" 200 713
10.10.1.32 - - [23/Feb/2016:12:40:45 +0200] "GET /asf-logo.png HTTP/1.1" 200 17811
10.10.1.32 - - [23/Feb/2016:12:40:45 +0200] "GET /bg-upper.png HTTP/1.1" 200 3103
10.10.1.32 - - [23/Feb/2016:12:40:46 +0200] "GET /favicon.ico HTTP/1.1" 200 21630
10.10.1.32 - - [23/Feb/2016:12:40:50 +0200] "GET /manager/html HTTP/1.1" 401 2538
10.10.1.32 - sa [23/Feb/2016:12:40:55 +0200] "GET /manager/html HTTP/1.1" 200 14084
10.10.1.32 - sa [23/Feb/2016:12:40:55 +0200] "GET /manager/images/tomcat.gif HTTP/1.1" 200 2066
10.10.1.32 - sa [23/Feb/2016:12:40:55 +0200] "GET /manager/images/asf-logo.gif HTTP/1.1" 200 7279
10.10.1.32 - - [23/Feb/2016:12:42:12 +0200] "GET /uniteh-bau/rest/settings/setServerName/tsrv HTTP/1.1" 404 -
10.10.1.32 - - [23/Feb/2016:13:01:20 +0200] "GET / HTTP/1.1" 200 11418
10.10.1.32 - - [23/Feb/2016:13:01:25 +0200] "GET / HTTP/1.1" 200 11418
10.10.1.32 - - [23/Feb/2016:13:01:25 +0200] "GET /tomcat.css HTTP/1.1" 200 5926
10.10.1.32 - - [23/Feb/2016:13:01:25 +0200] "GET /tomcat.png HTTP/1.1" 200 5103
10.10.1.32 - - [23/Feb/2016:13:01:25 +0200] "GET /bg-nav.png HTTP/1.1" 200 1401
10.10.1.32 - - [23/Feb/2016:13:01:25 +0200] "GET /bg-upper.png HTTP/1.1" 200 3103
10.10.1.32 - - [23/Feb/2016:13:01:25 +0200] "GET /bg-middle.png HTTP/1.1" 200 1918
10.10.1.32 - - [23/Feb/2016:13:01:25 +0200] "GET /asf-logo.png HTTP/1.1" 200 17811
10.10.1.32 - - [23/Feb/2016:13:01:25 +0200] "GET /bg-button.png HTTP/1.1" 200 713
10.10.1.32 - - [23/Feb/2016:13:01:48 +0200] "GET /uniteh-bau/rest/settings/info HTTP/1.1" 404 -
10.10.1.32 - - [23/Feb/2016:14:06:56 +0200] "GET / HTTP/1.1" 200 11418
10.10.1.32 - - [23/Feb/2016:14:08:41 +0200] "GET /uniteh-bau/rest/settings/setServerName/tsrv HTTP/1.1" 404 -
10.10.1.32 - - [23/Feb/2016:14:55:20 +0200] "GET / HTTP/1.1" 200 11418
10.10.1.32 - - [23/Feb/2016:14:55:30 +0200] "GET /uniteh-bau/rest/settings/setServerName/tsrv HTTP/1.1" 404 -
I use internet browser to test my app. But the only thing I can see is a blank page. In the logs all my requests are marked with 404 in the end of log. Did I something miss?
Those path's are all relative to the root (/) of your server. Tomcat doesn't work like that - you can see those three requests to /manager/ result in status 200.
Likewise, your .war is installed as a webapp under a certain name and all requests need to be relative to that webapp's name:
in that case, all requests must go to https://myserver.com:port/myWar/*
The issue could be caused if you used an apache httpd in front of the Tomcat which rewrote URLs and your links/bookmarks still point to the root-relative paths.
TL;DR: just go to the manager app and click on the link to your application.

Summing downloaded data by IP addresses

I have this file:
2001:778:0:1::21 - - [16/Sep/2011:12:30:46 +0300] "GET / HTTP/1.1" 200 44
2001:778:0:1::21 - - [16/Sep/2011:12:30:46 +0300] "GET /favicon.ico HTTP/1.1" 200 1406
2001:778:0:1::21 - - [16/Sep/2011:12:32:15 +0300] "GET / HTTP/1.1" 200 66643
88.222.10.7 - - [17/Sep/2011:23:39:25 +0300] "GET / HTTP/1.1" 200 66643
88.222.10.7 - - [17/Sep/2011:23:39:25 +0300] "GET /favicon.ico HTTP/1.1" 200 1406
88.222.10.7 - - [18/Sep/2011:13:45:39 +0300] "GET / HTTP/1.1" 304 -
88.222.10.7 - - [19/Sep/2011:05:47:35 +0300] "GET / HTTP/1.1" 200 66643
88.222.10.7 - - [19/Sep/2011:05:47:36 +0300] "GET /favicon.ico HTTP/1.1" 200 1406
121.141.172.40 - - [19/Sep/2011:20:32:07 +0300] "CONNECT 64.12.202.43:443 HTTP/1.0" 405 235
And I have IP addresses data (last number in each line), for example 44, 1406, 66643, 6664, .....
I want to sum all data that belongs to same IP address. So my results should be:
2001:778:0:1::21 68093 (44+1406+66643)
88.222.10.7 136098 (66643+1406+66643+1406)
121.141.172.40 235 (235)
Is is possible to do that in shell?
This should give you the desired output:
# awk 'BEGIN{FS=" "}{arr[$1]+=$10}END{for(i in arr) print i,arr[i]}' file
88.222.10.7 136098
2001:778:0:1::21 68093
121.141.172.40 235

Making the speed of SASS as fast as the CSS in Sinatra

Hi, let's look the code first.
I use the slim as the view template in Sinatra.
Snippet 1 : template file, index.slim
doctype html
html
head
title = #title
link rel='stylesheet' type='text/css' href='css/origin.css'
link rel='stylesheet' type='text/css' href='css/sass.css'
body
div This is a test for SASS
Snippet 2 : control file, route.rb that is a sinatra app file
require "sass"
configure do
set :sass, :cache => true, :cache_location => './tmp/sass-cache', :style => :compressed
end
get '/' do
#title = 'default page'
slim :index
end
get '/css/sass.css' do
sass :index
end
Snippet 3 :
style file
index.sass in my views folder that is a template path
div
color: white
background: green
origin.css in /public/css/orgin.css that is default style path
div {padding: 10px;margin: 10px;}
Snippet 4 :
This is the log of server that shows the speed of orgin css file and sass file
[coolesting#localhost ds]$ rackup
[2011-11-23 00:02:36] INFO WEBrick 1.3.1
[2011-11-23 00:02:36] INFO ruby 1.9.2 (2011-07-09) [i686-linux]
[2011-11-23 00:02:36] INFO WEBrick::HTTPServer#start: pid=5285 port=9292
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET / HTTP/1.1" 200 283 0.0261
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET /css/origin.css HTTP/1.1" 304 - 0.0005
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET /css/sass.css HTTP/1.1" 200 64 0.0060
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET / HTTP/1.1" 200 283 0.0029
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET /css/origin.css HTTP/1.1" 304 - 0.0005
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET /css/sass.css HTTP/1.1" 200 64 0.0029
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET / HTTP/1.1" 200 283 0.0190
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET /css/origin.css HTTP/1.1" 304 - 0.0005
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET /css/sass.css HTTP/1.1" 200 64 0.0043
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET / HTTP/1.1" 200 283 0.0029
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET /css/origin.css HTTP/1.1" 304 - 0.0005
127.0.0.1 - - [23/Nov/2011 00:02:38] "GET /css/sass.css HTTP/1.1" 200 64 0.0012
127.0.0.1 - - [23/Nov/2011 00:02:39] "GET / HTTP/1.1" 200 283 0.0056
127.0.0.1 - - [23/Nov/2011 00:02:39] "GET /css/sass.css HTTP/1.1" 200 64 0.0016
127.0.0.1 - - [23/Nov/2011 00:02:39] "GET /css/origin.css HTTP/1.1" 304 - 0.0187
127.0.0.1 - - [23/Nov/2011 00:02:39] "GET / HTTP/1.1" 200 283 0.0028
127.0.0.1 - - [23/Nov/2011 00:02:39] "GET /css/origin.css HTTP/1.1" 304 - 0.0005
127.0.0.1 - - [23/Nov/2011 00:02:39] "GET /css/sass.css HTTP/1.1" 200 64 0.0011
So, how to make the sass file running as fast as the origin css file, i have enabled the cache, but it slow than the origin css.
Or what solution to let the web server directly read the css file that is rendered from sass file.
:cache => true, :cache_location => '...' is used to configure the internal SASS cache (which creates .sassc files to save time while compiling to css). So this cache doesn't prevent your Sinatra app to run SASS every time the browser requests /css/sass.css.
What you really want is that SASS renders the css (compiled from index.sass) to the file public/css/sass.css. Then it would be picked up by the static loading mechanism like the public/css/original.css file is. To accomplish this, have a look at
http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options
specifically on the options :template_location and :css_location
You can always manually create the css files from scss and put them in your public directory. Otherwise the sass cache is already pretty fast.

removing time stamp from a text file using sed script

127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/ HTTP/1.1" 200 169 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/.treeinfo HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/Fedora HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/Server HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/Client HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/RedHat HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/CentOS HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/SL HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/directory.yast HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/current/images/MANIFEST HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/images/daily/MANIFEST HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/boot/platform/i86xpv/kernel/unix HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/platform/i86xpv/kernel/unix HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/STARTUP/XNLOADER.SYS HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/images/xen/vmlinuz HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/images/boot.iso HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/boot/boot.iso HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/current/images/netboot/mini.iso HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/install/images/boot.iso HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/ HTTP/1.1" 200 169 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/.treeinfo HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
1 27.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/Fedora HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/Server HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/Client HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/RedHat HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/CentOS HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/SL HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/directory.yast HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:35 +0530] "HEAD /sk/current/images/MANIFEST HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
How can I remove date from above logs using a sed script [08/Mar/2011:00:26:35 +0530] like this there are many instances.
You can use:
sed -r 's/\[[0-9]{2}\/[A-Z][a-z]{2}\/[0-9]{4}:[0-9]{2}:[0-9]{2}:[0-9]{2} \+[0-9]+\]//g'
See it on Ideone
Alternatively if there are no other occurrences of [..] in the input you can just do:
sed 's/\[.*\]//g'
If you have Ruby(1.9+)
$ ruby -i.bak -ne 'print $_.gsub(/\[.*?\]/,"")' file
if you absolutely must use sed
$ sed -i.bak 's/\[.[^]]*\]//g' file
The general pattern would be:
sed -e 's/pattern/replacement/' filename
With:
-e command
Append the editing commands specified by the command argument
to the list of commands.
In your case, this could be e.g.:
sed -e 's/\[.*\]//' yourfilename.log
Note that [.*] will work correctly as long as you don't have additional ] characters in a line.

Resources