Decryption of a "complicated" command in Linux



The shell is a very powerful tool, but scary, because it often seems very complicated. Today, I propose to make a step to understand how it all works, to not be afraid


history to see what we are dealing, here without further ado kifépeur the order.:


 wget -q -O - $ Pagelink | grep " .mp4" | cut -d "-f 4 | sed 's / 1080p / 720p / g 

I laid it seeking to recover the direct link of the videos on the site Jeuxvideo.com, since they are no longer available from the website redesign (were aimed at Mac’eux, who do not have the Flash horror). $ Pagelink therefore contains a link to a page of the site, which contains the coveted video as this page for example.

Reminder about the pipe: not I made no mistakes, the pipe is the name given to the “|”. Its utility, return the result of one command to another command. Our sample line is thus a sequence of commands that each works with the result of the previous.Let us see each step, starting with the beginning, the download page:


 
 
  Chronicle Speed ​​Game - Mirror's Edge back, finished in 30:45 
 
  
  

This result is then sent to this part:

 grep " .mp4" 

grep is a tool for you to return the lines of a file (or here, the result of wget), here the lines sought where is the “word” “.mp4”

 

Yes, one line! It then passes through the mill to the next part:

 cut -d "-f 4 

cut is a utility that, as its name indicates in the language of Shakespeare, cutting the string we give it in pieces following a separator, here “and told to return the f-th piece:

 http://video1080.jeuxvideo.com/chroniques/s/p/speed-game-mirror-s-edge-2-144960-1439971518-1080p.mp4

We approach the goal, having said as I not sick rate, I do not try the link to the video in Full HD, but at 720p. Luckily, just replace 1080p after the link 720p, and this is sed which supports:

 sed 's / 1080p / 720p / g 

Basically, replace “1080p” to “720p”. Why put the “p” at the end? To avoid overwriting also video1080 video720 by the beginning of the link, the risk of encountering errors:

 http://video1080.jeuxvideo.com/chroniques/s/p/speed-game-mirror-s-edge-2-144960-1439971518-720p.mp4

And now I have my final link)

For the record, I use that then link to download the video with wget, called either alone or with trickle. It’s about you? It’s normal, I talked to the article on download speed control . Otherwise Jeuxvideo.com point of interest is supported by youtube-dl , but I found that out after coded my thing.


Endless possibilities

We see, in the end, we have put together several tools that are each only one thing but do it well. Imagine that the controls are different Lego blocks, and think (or search the Web) to all these incredible creations as each other that are able to create people who play with. It’s the same, hard not to find a solution to a problem with such combination possibilities.


For example, when you have not the ability to have Fail2ban on hand, look in the log your the most violent IPs Web server classifying them by frequency of occurrence, why not banish 5 of the leading group, the most aggressive. Clearly, once mastered these commands “base”, only your imagination bridera you. . Enjoy


Source: seboss666


No comments:

Powered by Blogger.