Commands tagged sed (376)

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Pipe STDOUT to vim
The hyphen tells vim to open from STDOUT - saves having to create temporary files.

Rename files in batch

Check how far along (in %) your program is in a file
Imagine you've started a long-running process that involves piping data, but you forgot to add the progress-bar option to a command. e.g. $ xz -dc bigdata.xz | complicated-processing-program > summary . This command uses lsof to see how much data xz has read from the file. $ lsof -o0 -o -Fo FILENAME Display offsets (-o), in decimal (-o0), in parseable form (-Fo) This will output something like: . p12607 f3 o0t45187072 . Process id (p), File Descriptor (f), Offset (o) . We stat the file to get its size $ stat -c %s FILENAME . Then we plug the values into awk. Split the line at the letter t: -Ft Define a variable for the file's size: -s=$(stat...) Only work on the offset line: /^o/ . Note this command was tested using the Linux version of lsof. Because it uses lsof's batch option (-F) it may be portable. . Thanks to @unhammer for the brilliant idea.

find process associated with a port
e.g. fuser 25/tcp (see which pid is listening on smtp)

Show the key code for keyboard events include the Fn keys
The keycodes are a result of pressing: Mute (Fn+F1) a

kill ip connection
needed; apt-get install tcpkill

Sort by IP address

list block devices
Shows all block devices in a tree with descruptions of what they are.

Screenshot Directly To Clipboard
This will take a screenshot of a selected area and save it as foo.png as well as sending it straight to the clipboard for pasting into GIMP, Anki, Zim, etc.

Detect illegal access to kernel space, potentially useful for Meltdown detection
Based on capsule8 agent examples, not rigorously tested


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: