Unix command to print directory structure in the form of a tree? - unix

I am a newbie to UNIX, i want to print tree structure of files in a directory. below image is example in DOS, what will be the command of Unix to achieve same objective

I think you are looking for the "tree" command. If you are having issues running it you might have to find out how to install it on your specific distribution. For ubuntu installs you can find instructions here:
https://askubuntu.com/questions/507588/not-able-to-install-tree-comand-in-ubuntu
Not sure what you mean by "on Unix". What OS are you running, specifically? Tree should be compatible on Unix systems. You may just have to compile it for your particular OS.
This command prints output like the following (on cygwin):

Related

How do you run Octave in Jupyter?

I want to run Octave in JupyterLab on a M1 Macbook. I have installed JupyterLab using pip and Octave-6.3.0-beta1.dmg file as per the prerequisites.
I have also installed Octave kernel using pip install octave_kernel --user. Now I am somewhat stuck. This documentation says, "We require the Octave executable to run the kernel. Add that executable's directory to the PATH environment variable or use the OCTAVE_EXECUTABLE to point to the executable itself." Can someone help me with this? What am I supposed to type in the terminal?
PATH is an "environment variable". It basically makes anything that runs in your computer know few software and their location. That way, when you do e.g. python my_code.py it knows what python is.
Read the link above too to learn how to add stuff to PATH, in your case, the location of Octave. The location should be something like C:\Octave\Octave-5.1.0.0\mingw64\bin, where the folder contains octave.bat, for a windows machine. Just find wherever Octave is in you MAC.
There is another similar question about this: How to add Octave to PATH environment variable in Mac Sierra?

How to make R executable file

Is it possible to create an executable file where I can just upload the excels and an output is generated based on the coding and without sharing it as well.
On Linux or OSX you can make an R script double clickable with the shebang trick:
Add #!/usr/bin/Rscript as the first line
Make the script executable with chmod +x
On OSX, there is also the option to convert an R script into an application bundle with Platypus. On Windows, I do not know whether this is easily achievable at all, especially as executables usually are not placed in the search path on Windows.
is using R-Shiny apps can cover that? Its an R based program and you can customize the output / logic there.

Mac to Windows Compatibility with an R Script Calling Bash

Current script
I work on Mac OSX. I have an R script that I like to use to organize my files and produce .pdf via LaTex. In order to (1) produce the .pdf with LaTeX and (2) manipulate some files and directories I use Bash script from R with system("").
From Mac to Windows
I would like to offer this R script (once compiled to make an executable) to someone that knows nothing about programming and uses Windows. I have no idea how the windows prompt commands work and what language it uses. I am afraid that (1) I cannot use the function system("") on Windows and (2) I cannot use bash such as system("rm dir/file.txt").
Question
What do you think would be the easiest for me in order to make my script compatible with Windows (given that I know nothing about Windows)? Will I be able to use system("") and Bash from R on Windows?
I think the best solution is to handle both cases separately (keep in mind that windows paths are also different from unix paths).
if(.Platform$OS.type == "unix") {
system("rm dir/file.txt")
[...]
}
else {
system("DEL /Q dir\file.txt")
[...]
}
You should have no problem searching for unix equivalent commands in windows cmd.
Also keep in mind that if you need the R script to exec LaTeX binaries, it would pretty much kill the portability because of the huge dependencies that LaTeX has.

Why am i able to run unix commands on my PC?

How am i able to execute UNIX commands on my PC Command prompt? Note i do not have cygwin installed, although i was going to before i discovered this.
This is a development machine so i have a lot installed on it like ruby, python, git, github, node and so on.
What does this mean? can i use this without cygwin?
Here is a list of programs installed on my PC program list
How am I able to execute UNIX commands on my PC Command prompt?
You can use the where command in a cmd shell to find out the exact location of your Unix commands, for example:
where ls
This assumes, of course, that ls is located somewhere in your current PATH.
The location returned will show you in which directory your Unix commands are installed and may be enough for you to determine how they were installed.
The where command is roughly equivalent to the Unix which command.
By default, the search is done in the current directory and in the
PATH.
Syntax
WHERE [/r Dir] [/q] [/f] [/t] Pattern ...
WHERE [/q] [/f] [/t] [$ENV:Pattern
Source where
Further Reading
An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
where - Locate and display files in a directory tree.
Running Unix commands in windows can be done by having a tool like Cygwin which has those commands.
You can also get many of those commands compiled for windows and then run them using the command with the full path or only the command if the executable is in a path known by adding the paths to the executable files in Windows by :
1) Running in the terminal: PATH %PATH%;C:\<new_path>
2) Creating command aliases like: doskey np=C:\<new_path>\new_command.exe $*. $* is used to be able to transmit parameters

tree command is not working in UNIX OS?

I am new to UNIX OS, tree command is not working on UNIX below is error, can you explain why it is so?
$tree
nologin: tree: not found
If you are having issues running tree command on UNIX, it may be not install on your UNIX OS, you might have to find out how to install it on your specific distribution.

Resources