Command Line

Subscribe to Command Line feed
This is for anything regarding the command line, in any operating system. All questions (including dumb ones), tips, and interesting programs/console applications you've found or made yourself are welcome. Linux / BSD / OSX / Windows CLI apps or questions or comments, we're happy to take them all!Command Line
Updated: 11 min 37 sec ago


9 hours 3 min ago

I've been trying out Lynx these past few days. It works really well for most of the stuff I want to do. The only issues I'm having so far:

  • I can't upvote or downvote on reddit, because Lynx doesn't have Javascript. I would like to be able to do that, but I'm not sure I want to install Reddit Terminal Viewer just for that. Is there a workaround?

  • For a lot of websites I have to scroll through ten pages of stuff before I can get to the content. Is there a way to script with Lynx so that I can tell it not to display stuff like this?

submitted by /u/NyquilPepsi
[link] [comments]

How do I break a string into "words" when I don't know how many of them there will be?

Fri, 03/16/2018 - 23:53

I'm writing a shell script (on OSX) to parse the Unicode XML character database.

I'm trying to create a table that will contain a base codepoint, followed by a string containing the replacement codepoints for casefolding.

My xmlstarlet command to get all the applicable characters is:

"$UCD_Data" is the path and filename to the XML file containing the codepoints, it's 180MBs...

CodePointAndReplacementString=$(xmlstarlet select -N u="" -t -m "//u:char[@NFKC_CF != '' and @NFKC_CF != '#']" -n -v @cp -o ';' -v @NFKC_CF "$UCD_Data")

That works fine, and a sample of what the CodePointAndReplacementString variable contains is here:

0F78;0FB3 0F80 0F79;0FB3 0F71 0F80

The semicolon separates the codepoint to replace, and the string to be substituted.

Anyway, my question is, how do I break everything after the semicolon into multiple codepoints, so that I can then use the printf utility to output the string with the correct formatting?

in C, I would measure the size of the string after the semicolon, then search for a space, and copy from offset to offset into it's own variable, but that's not really possible in shell scripting as far as I can tell.

submitted by /u/bumblebritches57
[link] [comments]

Port applications to different operating systems from the command line with tonixxx

Fri, 03/16/2018 - 20:44

Hiya! I'm plugging a wrapper I wrote around Vagrant to organize cross-platform builds, basically you configure your buildbots and tonixxx loops over each one, compiling and testing your project for each target platform. Let me know whacha think!

submitted by /u/mcandre
[link] [comments]

find -exec, xargs, and ctags

Thu, 03/15/2018 - 22:10

I have sources/ folder containing a large number of java classes that I would like to generate ctags for and use them in vim.

My first attempt was:

$ find -type f -name '*.java' | xargs ctags

I tried following tags in vim, but noticed that some were working and some were not. When I looked at the tags file, I noticed that the definitions were indeed missing.

My second attempt was:

$ find -type f -name '*.java' -exec ctags {} +

Same issue with this one.

My final attempt was:

$ ctags `find -type f -name '*.java'`

This worked! I could navigate to all the tags in vim and saw the definitions in the tags file.

Why did xargs and find -exec not work? I would like to know and understand the reason. Thanks!

submitted by /u/kevko5212
[link] [comments]

Are the differences between GNU/Linux command line tools and Mac/BSD tools very big?

Thu, 03/15/2018 - 09:23

I need to start a project at work (an open source shop that uses mostly Apple hardware) and I plan on implementing scripts and tools that are mostly going to be based in bash and python, but I will also be using tools like cron, sed, awk, find and psql.

I'm experienced with these tools in Linux, but the network guy is having a hard time getting a Linux machine integrated and I may have to settle for a Mac.

So my question is, given I know these tools only from Linux, will the Mac versions be similar enough, or do I need to relearn any of them? Also, is homebrew basically the equivalent of something like apt-get?

submitted by /u/COAST_TO_RED_LIGHTS
[link] [comments]

Tool to convert webpage to clean markdown

Wed, 03/14/2018 - 20:28

Is there some tool which converts webpages into clean markdown? I used to use the Evernote web clipper for this but since I stopped using Evernote I wanted an alternative. Basically I want to be able to save articles from the web as a clean markdown file.

submitted by /u/Lord_Uber_Dowzen
[link] [comments]

What is a good command line tool for browsing Twitter?

Tue, 03/13/2018 - 18:38

Ive been looking for a good cli tool for viewing Twitter similar to rtv (Reddit terminal viewer).

Anyone know of any good ones?

submitted by /u/thenightwolf51
[link] [comments]

Looking for a CLI way to organize the music I like

Sun, 03/11/2018 - 18:32

So I am looking for a CLI way to organize the music I like. It consists of rips from CDs, rips from Youtube where many tracks aren't published elsewhere, as well as lots of music on Spotify. However I am looking for a unified way of organizing this mess, specifically:

  • Beets works perfectly when importing music that came cleanly from a CD, less so when importing stuff from Youtube, specifically stuff that isn't listed on MusicBrainz. Also, editing tags and browsing the library is a bit of pain, does a ncurses frontend exist?
  • Ncmpcpd+mpd are great for playing music saved on my computer, what about all the streaming services? I know that there is some software that can work as Spotify client, what about the other services?
  • Finally, is there software that allows me to save a track in it without an associated file, but keeping track of streaming links? Such that I can have an Album saved and play it on a set of streaming services, or purchase a personal copy if I wish so?

Looking forward to your suggestions.

submitted by /u/Taenk
[link] [comments]

Duplicating a directory structure not working (for the purpose of doing search and replace on binary files)

Sun, 03/11/2018 - 16:31

I need to do a search and replace on over 600 binary files in multiple folders. The changed files will have to be saved in a new folder because if you try and write to the file you're reading, it creates a zero length file (and the original directory tree is read-only).

Here's my main command: it fails because it says that the folders have not been created yet.

find /media/frodo/DCS/ -type f -print0 | xargs -0 -I {} bbe -e 's/20160808/20160809/' -o /home/frodo/mri/{}

** Note: I have about 6 other -e commands that I'm adding too.

So I tried to create the folders ahead of time, but no variation of the following will work:

find /media/frodo/DCS/ -type f -print0 | xargs -0 -I {} mkdir "$(dirname /home/frodo/mri{})" find /media/frodo/DCS/ -type f -print0 | xargs -0 -I {} mkdir "$(dirname /home/frodo/mri\{\})" find /media/frodo/DCS/ -type f -print0 | xargs -0 -I {} mkdir "$dirname /home/frodo/mri{}" find /media/frodo/DCS/ -type f -print0 | xargs -0 -I {} mkdir "$dirname /home/frodo/mri{}"

Most of the time it also creates a folder called {}, but otherwise it creates folders with the FILENAMES too! e.g. if I have /media/frodo/DCS/1234/ it will create the correct directory structure under /home/frodo/mri but will also create a folder called ""

I think if I could just get the directory structure duplicated then the bbe command might work.

Oh, how stupid! Perhaps if I did "-type d" then I could dispense with the dirname command and it might work. However, the dirname should work since it works on an individual file when I run it. I just don't know why it won't work on the list of files from xargs

No, it still doesn't work!

find /media/frodo/DCS/ -type d -print0 | xargs -0 -I {} mkdir /home/frodo/mri{}

mkdir: cannot create directory ‘/home/frodo/mri/media/frodo/DCS/’: No such file or directory mkdir: cannot create directory ‘/home/frodo/mri/media/frodo/DCS/dicom’: No such file or directory mkdir: cannot create directory ‘/home/frodo/mri/media/frodo/DCS/dicom/9961’: No such file or directory etc. /home/frodo/mri>ls -l total 0 submitted by /u/mk_gecko
[link] [comments]

Google Assistant from the Command Line?

Sun, 03/11/2018 - 06:27

Hi! I'm looking for a way I can type to Google Assistant in the command line and get back the text as a message on my screen (plus take whatever actions I've asked it to, I mostly foresee myself using this as a "Note to Self" thing). I've found this link and it looks like it does what I want except it's all audio (speak to the computer, listen to the response). I want to type to the computer and read the response. Is this possible?

submitted by /u/doulos05
[link] [comments]