- From the following text, print only the lines that start with a word that has only uppercase characters:
hello - don't print me
HELLO - but I'm ok
Im a line that shouldn't be printed
BUT I'm a line that should
- Given input file of the form:
# one of these shells.
/bin/bash
/bin/csh
Translate each file path to windows style path and print:
# one of these shells.
C:\bin\bash
C:\bin\csh
From the following log file:
167.86.115.113 - - [26/Dec/2019:00:25:59 +0200] "GET / HTTP/1.1" 200 1993 "-" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"
167.86.115.113 - - [26/Dec/2019:00:26:01 +0200] "GET /HNAP1/ HTTP/1.1" 404 1772 "https://178.79.150.27/" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"
167.86.115.113 - - [26/Dec/2019:00:26:01 +0200] "GET /hudson/script HTTP/1.1" 404 1772 "https://178.79.150.27/" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"
167.86.115.113 - - [26/Dec/2019:00:26:02 +0200] "GET /script HTTP/1.1" 404 1772 "https://178.79.150.27/" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"
84.110.208.186 - - [26/Dec/2019:00:37:57 +0200] "-" 408 5165 "-" "-"
77.124.5.143 - - [26/Dec/2019:01:32:58 +0200] "-" 408 543 "-" "-"
23.95.84.74 - - [26/Dec/2019:01:41:20 +0200] "-" 408 1373 "-" "-"
169.197.108.6 - - [26/Dec/2019:02:23:56 +0200] "GET / HTTP/1.1" 200 1814 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
52.41.211.72 - - [26/Dec/2019:04:23:07 +0200] "HEAD / HTTP/1.1" 200 1899 "-" "Go-http-client/1.1"
66.249.66.10 - - [26/Dec/2019:04:57:14 +0200] "GET / HTTP/1.1" 200 2406 "-" "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
157.55.39.2 - - [26/Dec/2019:05:22:21 +0200] "GET /robots.txt HTTP/1.1" 404 2274 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
157.55.39.2 - - [26/Dec/2019:05:22:22 +0200] "GET /robots.txt HTTP/1.1" 404 2274 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
157.55.39.70 - - [26/Dec/2019:05:22:31 +0200] "GET / HTTP/1.1" 200 2495 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
35.175.224.215 - - [26/Dec/2019:07:00:51 +0200] "GET / HTTP/1.0" 400 0 "-" "-"
77.124.127.86 - - [26/Dec/2019:07:59:28 +0200] "-" 408 543 "-" "-"
77.124.127.86 - - [26/Dec/2019:07:59:28 +0200] "-" 408 543 "-" "-"
66.249.66.40 - - [26/Dec/2019:08:04:46 +0200] "GET / HTTP/1.1" 200 2406 "-" "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
84.110.208.186 - - [26/Dec/2019:08:06:07 +0200] "-" 408 543 "-" "-"
169.197.108.38 - - [26/Dec/2019:08:44:04 +0200] "GET / HTTP/1.1" 200 1814 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
45.79.152.7 - - [26/Dec/2019:09:57:12 +0200] "GET / HTTP/1.0" 200 2977 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:00:20 +0200] "-" 408 156 "-" "-"
169.197.108.42 - - [26/Dec/2019:10:02:20 +0200] "GET / HTTP/1.1" 200 1814 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
84.110.208.186 - - [26/Dec/2019:10:03:56 +0200] "-" 408 543 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:05:09 +0200] "-" 408 543 "-" "-"
45.79.152.7 - - [26/Dec/2019:10:11:50 +0200] "HEAD / HTTP/1.1" 200 2065 "-" "Mozilla"
45.79.152.7 - - [26/Dec/2019:10:12:07 +0200] "HEAD / HTTP/1.1" 200 2065 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a3pre) Gecko/20070330"
185.3.145.39 - - [26/Dec/2019:10:15:01 +0200] "-" 408 543 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:24:10 +0200] "-" 408 543 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:24:10 +0200] "-" 408 543 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:25:40 +0200] "-" 408 156 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:25:40 +0200] "-" 408 156 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:25:40 +0200] "-" 408 156 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:25:40 +0200] "-" 408 156 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:32:12 +0200] "-" 408 156 "-" "-"
185.3.145.39 - - [26/Dec/2019:10:32:19 +0200] "-" 408 543 "-" "-"
82.81.7.123 - - [26/Dec/2019:10:32:24 +0200] "-" 408 4720 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:34:22 +0200] "-" 408 543 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:34:22 +0200] "-" 408 543 "-" "-"
185.3.145.39 - - [26/Dec/2019:10:44:27 +0200] "-" 408 543 "-" "-"
84.110.208.186 - - [26/Dec/2019:10:46:26 +0200] "-" 408 543 "-" "-"
-
Print a list of all IP addresses that sent partial HTTP requests (server response was 408). For each address print how many times it tried to access the server.
-
Print a list of all URLs for which the server returned an 404 error. Sort that list by url access frequency.
Given the following input:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether f4:0f:24:29:df:4d
inet6 fe80::1cb5:1689:1826:cc7b%en0 prefixlen 64 secured scopeid 0x4
inet 10.176.85.19 netmask 0xffffff00 broadcast 10.176.85.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
en1: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500
options=60<TSO4,TSO6>
ether 06:00:58:62:a3:00
media: autoselect <full-duplex>
status: inactive
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
ether 06:0f:24:29:df:4d
media: autoselect
status: inactive
Create a CSV file from the data as follows:
interface,inet,status
lo0,127.0.0.1,
gif0,,
en0,10.176.85.19,active
en1,,inactive
p2p0,,inactive
Extract the columns: Sample Temp (Kelvin) and Samp HC (J/mole-K) from the following input. Ignore all lines before [Data] starts:
Input:
[Header]
TITLE,xxxxxxxx.dat
BYAPP,HeatCapacity,3.8.14,1.7
INFO,2.29,MASS:Sample Mass (mg)
INFO,,MASSERR:Sample Mass Error (mg)
STARTUPAXIS, X, 8, LINEAR, AUTO
STARTUPAXIS, Y1, 10, LINEAR, AUTO
[Data]
Time Stamp (Seconds),Comment (),Puck Temp (Kelvin),System Temp (Kelvin),Sample Temp (Kelvin),Temp Rise (Kelvin),Samp HC (J/mole-K),Samp HC Err (J/mole-K),Addenda HC (uJ/K),Addenda HC Err (uJ/K)
41022684.5,,300.013,299.45,302.94831,6.228222,124.32831,0.85,8872.3999,4.515
41022942.84,,300.066,299.351,302.70334,5.6470045,123.05087,0.8188,8867.6331,4.515
41093651.75,,6.944,7.7512,6.9778851,0.13327843,0.037876781,0.0009362,3.4701983,0.005059
41094250.64,,6.69529,7.3013,6.7421403,0.1326991,0.03380048,0.0008134,3.1694344,0.004567
41094277.06,,6.68978,7.2966,6.7338561,0.12852694,0.033751509,0.0007938,3.1593382,0.004551
Expected Output:
302.94831,124.32831
302.70334,123.05087
302.69056,122.93617
6.9761565,0.037976428
6.9772032,0.037621912
6.9778851,0.037876781
6.7421403,0.03380048
6.7338561,0.033751509
Write a python script for mass renaming music files according to labels. The script takes an existing format of files in
current directory and an expected output format and prints a list of old -> new file name tuples.
Format can be any string that contains any number of the labels: <artist>
, <album>
, <track>
, <year>
Assume file names match input format.
Sample list of input files:
Bob Dylan - 01 You're No Good (1962).mp3
Bob Dylan - 02 Talkin' New York (1962).mp3
Bob Dylan - 03 In My Time of Dyin' (1962).mp3
Bob Dylan - 04 Man of Constant Sorrow (1962).mp3
Bob Dylan - 05 Fixin' to Die (1962).mp3
Bob Dylan - 06 Pretty Peggy-O (1962).mp3
Sample input format:
<album> - <track> <title> (<year>).mp3
Sample output format:
Bob Dylan/<year> <album>/<track> <title>.mp3
Expected output:
Bob Dylan - 01 You're No Good (1962).mp3 -> Bob Dylan/1962 Bob Dylan/01 You're No Good.mp3
Bob Dylan - 02 Talkin' New York (1962).mp3 -> Bob Dylan/1962 Bob Dylan/02 Talkin' New York.mp3
Bob Dylan - 03 In My Time of Dyin' (1962).mp3 -> Bob Dylan/1962 Bob Dylan/03 In My Time of Dyin'.mp3
Bob Dylan - 04 Man of Constant Sorrow (1962).mp3 -> Bob Dylan/1962 Bob Dylan/04 Man of Constant Sorrow.mp3
Bob Dylan - 05 Fixin' to Die (1962).mp3 -> Bob Dylan/1962 Bob Dylan/05 Fixin' to Die.mp3
Bob Dylan - 06 Pretty Peggy-O (1962).mp3 -> Bob Dylan/1962 Bob Dylan/06 Pretty Peggy-O.mp3
Bonus: also rename the files and create required directories along the way