Move folders using Terminal by referencing a CSV file

I have a CSV file containing the following two columns:

  1. Column A: From Directory (e.g. /Volumes/Backup Plus/Salesforce/Order Test/OR-1000049439).

  2. Column B: To Directory (e.g. /Volumes/Backup Plus/Salesforce/Opportunity Test/Q-DNYE20180508-2308).

I need to write a script in Terminal that will loop through the CSV and move the directory from Column A into the directory from column B. The end result would be the OR-1000049439 folder residing inside the Q-DNYE20180508-2308 folder). There are roughly 13,000 rows in which I need this to occur.

Can someone please help me on how to do this?


Here is a copy of the first few rows in the CSV file:

enter image description here

I need the folder in A2 to end up in the folder on B2. I need the folder in A3 to end up in the folder on B3, etc…

Hopefully that helps enough.

Update 2:

Brians-MacBook-Pro:Data Migration briangannuscio$   Head OrderFileV2.csv /Volumes/Backup Plus/Salesforce/Order Test/OR-1000049439,/Volumes/Backup Plus/Sa/Volumes/Backup Plus/Salesforce/Order Test/OR-1000050080,/Volumes/Backup Plus/Sa/Volumes/Backup Plus/Salesforce/Order Test/OR-1000050081,/Volumes/Backup Plus/Salesforce/Opportunity Test/Q-RGORD20170207-1526  Brians-MacBook-Pro:Data Migration briangannuscio$   File OrderFileV2.csv OrderFileV2.csv: ASCII text, with CR line terminators 

Terminal and files apps no longer open

I’m new to Linux and am currently using it to run a Minecraft server. I got everything working but then I restarted and no matter what I do terminal or files won’t open. I click on the app and it says it’s loading but never opens. Firefox, settings, and pretty much every other app can open. The only thing I changed before this happened was turning on speed step in the BIOS, I tried turning It back off and I still have this problem. I can get the server running by putting it in the start up app, bit no terminal will show up, but I can connect to the server so I know it’s running.

Node program runs in Terminal, but not as a service or on command “do shell script” from AppleScript

I have a call (mercury-parser via Yarn) that converts Web pages to lines of structured text. It runs in node on 3.5 GHz, 6-Core Mac Pro (MacPro6,1) with 16GB RAM and D700 GPUs, running macOS 10.14.5 very well, but I’m struggling to run it as a service / on demand without opening terminal app and typing.

I would much prefer it to run within an AppleScript. Here is the line of code:


If I run it in Terminal (using either /bin/bash or /bin/sh), I get the proper result: fourteen lines of structured text from the Web page.

If I run it in a shell script, starting with either “#!/bin/sh” or “#!/bin/bash”, I get: env: node: No such file or directory If I run it in Script Editor as: do shell script “/Users/me/.yarn/bin/mercury-parser” I get: env: node: No such file or directory

Here are both my .profile and my .bash_profile texts:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$  PATH"  export PATH="$  HOME/.yarn/bin:$  HOME/.config/yarn/global/node_modules/.bin:$  PATH"  [[ -s $  HOME/.nvm/ ]] && . $  HOME/.nvm/  # This loads NVM  source ~/.nvm/  export NVM_DIR="$  HOME/.nvm" [ -s "$  NVM_DIR/" ] && . "$  NVM_DIR/" # This loads nvm 

What do I have to do to get the code to run outside of Terminal?

autossh working fine from terminal, bot causing permission denied from systemctl

I’m trying to integrate autossh on a raspberry pi.

if I launch the command by itself

autossh -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -N -R 22002:localhost:22 user@myserver 

everything works fine, but launching the same command from systemctl

[Unit] Description=AutoSSH tunnel service Remote port 22002 to local 22 [Service] Environment="AUTOSSH_GATETIME=0" ExecStart=/usr/bin/autossh -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -N -R 22002:localhost:22 [Install] 


Jun 25 13:43:22 pi autossh[995]: Permission denied, please try again. Jun 25 13:43:22 pi autossh[995]: Permission denied, please try again. Jun 25 13:43:22 pi autossh[995]: Permission denied (publickey,password). Jun 25 13:43:22 pi autossh[995]: ssh exited with error status 255; restarting ssh 

I am able to ssh my server without password from my pi.

anything i should check up or do ?


How to enroll Macs on Profile Manager MDM using Terminal?

I’ve been tweaking the command profiles quite sometime now but the -password parameter doesn’t work. I’ve wanted to enroll machines using an MDM profile but it will require the user to input credentials via prompt which defeats our automation.

Additional: I can install Trust profiles from macOS server via terminal by simply executing `profiles -I -F but not the MDM.

How to Edit Files From Your Linux VPS Terminal

There is a constant need to read, edit and change text files on any VPS, mostly after the installation of new packages. Learning, practicing and gaining proficiency with command line text editors can mean a world of difference in your experience and results with VPS.

If your server runs into a trouble, the only resource will be access to system console and the only way to use it will be through a text editor. About the only editor that is guaranteed to exist everywhere is Vi or its descendant, Vim. In this tutorial, we will study nano and Vim, two popular text editors that you can run from a VPS terminal.

Vi Editor

A problem for most newcomers to VPS is that vi, the only text editor that is by default present on any Linux distribution, is neither WYSISWYG nor intuitive. If you expect it to obey commands from Windows Notepad or MacOS TextEdit editors, you’ll be frustrated and disappointed in no time. Let’s say you are following a script to install some widely used program, say Nginx, and that it contains a command such as

sudo vim /etc/nginx/nginx.conf 

If this is your first contact with vi, you will discover that

A) you cannot type into the editor (unless you by chance press i on the keyboard) and that

B) you have no idea how to save the file and leave the editor (until you find out that :wq will do the trick).

Vim Editor

In time, an enhancement of vi called vim, became very popular with power users. It is an almost strict superset of vi but with dozens of additional features sucs as protocols, plugins, tasks automation, working with several files at once, using its internal language VimScript or more formal Python, Ruby, Perl, or Tcl as scripting languages, and so on.

Vim is difficult to learn completely, but well worth the effort.

Nano Editor

Problems that newcomers have with Vi / Vim is the reason why another editor, nano, is so popular. It will show the available commands as a menu on screen, and when you start typing, you will see text filling in. No wonder the first thing many users do after installing a “droplet”, an “instance” or a “server” on their VPS boxes, will be to install nano.

What We Are Going To Cover

For nano and Vi / Vim we shall demonstrate how to:

  • Install the editor on Debian / Ubuntu and Centos
  • Explain the philosophical approach to editing
  • Get help
  • Create new or open an existing file
  • Show important commands within the editor
  • Save file and exit


  • Debian / Ubuntu or Centos systems
  • Ability to SSH into the server
  • Since Vim is a superset of Vi, we are going to concentrate on Vim only

Installing Editors on Ubuntu 16.04 and Debian 9

Vi should be present on all servers, however, on some it may actually envoke Vim. We are showing commands for installation on all systems as there may be differences amongst hosting providers and server versions provided.

First update and upgrade the current version of Ubuntu / Debian:

sudo apt update sudo apt upgrade 

Depending on the version of Debian, the sudo command may not be recognized immediately after the server is installed. If that is the case, just omit sudo from the commands.

On Ubuntu only, if you get the following prompt:

just press Tab on the keyboard and then Enter.

You may then install updates, if any:

sudo apt dist-upgrade  

Then, install Nano:

sudo apt install nano 

We see that it is already installed on Ubuntu 16.04:

Let’s now install Vim:

sudo apt install vim 

It comes preinstalled as well.

Installing Editors on Centos 7

The commands are:

sudo yum update sudo yum install nano sudo yum install vim 

How to Start the Editor

To start an editor, you invoke it by its name at the command prompt. If you add a file name, two things can happen. If there is no file at that address, the editor will create an empty file, and if the file exists, it will be opened in the editor.


When To Use Nano

This is the ideal case for using nano: you are (fairly) new to VPS servers, but you have just acquired one in order to run one specific program on it, or a couple of sites. So you snoop around and find a good recipe for installing your software of choice, you follow along and you reach a point when a config file needs to be changed. Nano is an ideal editor for such small, quick and dirty jobs, where you add a line or two, say, tweak site name for Nginx and so on, then save and close the file.

Now move to a neutral folder such as /tmp and open a file called sometext.txt in it:

cd /tmp nano sometext.txt 

We can start typing new text right away or we can paste a text we already have in clipboard. If it’s a terminal window under Windows (such as Kitty or Putty), you will paste text with the right click of the mouse and if it’s under MacOS, a simple Cmd-V should do.

I have copied the above paragraph and this is what I’ve got:

The text is all in there but you see only its very end. Nano by default does not wrap text as that is the expected behaviour when you edit configuration files. To change to wrapped text, press Esc, release it, and then press $ :

That was soft wrapping, hard wraps are turned on or off with Esc + L.

The normal way to issue commands in nano is through Ctrl key plus a letter, which is denoted as ^G – meaning press Ctrl and then pres key g while still holding Ctrl. In the menus, nano uses upper-case G so it seems you have to press the Shift key and then g but actually, you do not have to press Shift at all.

Instead of Esc followed by a key press, you can also use key Alt with a simultaneous key press. So hard wrap would mean pressing Alt, holding it, then pressing Shift, holding it, then pressing l. In general, Alt and Esc are called meta keys and – depending on your keyboard – some other key may be assigned that role.

Help Screen in nano

Ctrl-G will get you main nano help text on screen:

Scroll down with combinations of ^Y and ^V or, if on a normal PC / Mac keyboard, just use PageUp and PageDown keys. You can also scroll with cursor keys, up and down.

We’ll now study keyboard combinations a bit more:

Commands starting with M, for instance, M-(, call for pressing the Meta key, which, as we have seen already, can be Esc, Alt or something else. So you can go to the beginning of the paragraph by pressing Esc, release pressure, then press on Shift and 9 at the same time. Or, you can press Alt, keep the key pressed, press on Shift, hold both keys pressed and then press on 9.

Press on Ctrl-X to leave the help screen.

Saving File With nano

To save file with nano, use Ctrl-O. The menu at the bottom changes to:

To save the file with changes, just press Enter.

Pressing on Ctrl-X will leave nano if the file is saved; if not, it will ask for confirmation with Y.

From the main menu, we see that Ctrl-W will find text, _Ctrl-_ is for the replace operation and so on.

Vim Editor

Learning Vim With Vimtutor

The best way to learn Vim is to start a special version of Vim called vimtutor:


You are in Vim right away, and in its “normal” mode. It means pressing keys on the keyboard will not enter text but will be interpreted as interactive commands. To move cursor press on keys h, j, k, and l. Pressing j, for instance, will move cursor one row below. Keep pressing j until you see the second screen in vimtutor:

and then proceed with learning from there.

Running Vim

Run the following command


and you’ll get this window:

It’s easy to create or open a file with Vim:

vim anothertext.txt 

Three Modes of Operation in Vim

Vim has several modes of operations but these three are the most important:

  • NORMAL MODE – cursors, moving through text, text buffers, text manipulation etc.
  • INSERT MODE – inserting text: typing and editing.
  • VISUAL MODE – mode in which larger blocks of text can be defined, cut out, pasted and so on.

Press Esc twice to return to the normal mode.


If you want to type text, press i in the normal mode to ignite the Insert mode. You’ll see the word — INSERT — in the lower left corner of the window and you’ll be able to enter text.

In insert mode, I copied the above paragraph and right clicked on the mouse – the text appeared in Vim editor.

The Command Mode in Vim

You start issuing commands by typing a colon. For example, type :h for help and the following help screen will show up:

Type :q to get back to the screen with text.

To leave the file and exit the editor, enter:


To quit vim without saving the file, enter:


Here are the basic commands:

  • save: :w
  • save and exit: :wq
  • exit: :q
  • force: ! (example :w! :q!)
  • copy: y
  • copy a line: yy
  • paste: p
  • cut: d
  • cut a line: dd

Typing a number in front of command will execute that command that number of times. That means that if w is a command to move cursor to the beginning of the next word, 15w will move cursor 15 words to the right.


Typing V in normal mode will turn on the Visual mode.

Note the label VISUAL LINE in the lower left corner of terminal window.

In this mode pressing keys such as j and k will move cursor up and down but will also mark a white block of text. Since we have pressed V, entire lines with cursor will be marked. Press v to enable character- based visual selection of text, in which case, the lower left corner will show only the word VISUAL.

Now, to delete text, press d (delete) and press y (yank) to copy the marked region. Then move the cursor to the desired paste location; pressing p will then paste after the cursor, while P will paste before it.

Press c to change text… and for further commands be sure to devote more time to learning Vim than you expected!

What Can You Do Next

We have shown basic editing capabilities of two almost universally present text editors, nano and Vi or Vim. They may not be your cup of tea at all, but you should at least learn enough of Vi / Vim to read a file, edit and then save it. Other famous editors we have no space to do justice here are Emacs, Micro, NE, and there are many others to choose from for your VPS!

Dusko Savic is a technical writer and programmer.

The post How to Edit Files From Your Linux VPS Terminal appeared first on Low End Box.

How to change Ubuntu’s terminal name

enter image description here

I’ve been reading about this topis here and tried the solution given to change the terminal name (refer to the picture on item number 1)

But none of them can change the terminal’s name (item number 1).

user@linux:~$   gnome-terminal --title="SOME TITLE HERE" user@linux:~$     user@linux:~$   PROMPT_COMMAND='echo -ne "3]0;SOME TITLE HERE7"' user@linux:~$     user@linux:~$   echo -ne "3]0;SOME TITLE HERE7" user@linux:~$    

I know that item number 2 can be changed with PS1. But the title (item number 1) still didn’t change even after I change the PS1

user@linux:~$ is fine. I don’t want to change this, I just want to rename the terminal’s title on the top (item number 1)