8/30/18
"oobuntu"
pwd
(Print working directory) Displays your current directory
ls
Displays the set of files contained within the current directory
ls -l
Displays the "long listing format" of the files within the current directory
mkdir new_directory
Creates a new folder named "new_directory"
"mk" means make
"dir" means directory
**In general, if
..
is used, it goes up the command chain to the parent object
**In general, if you use the / between .. then the parent function's directory can be done as many times as you would like
ls ..
Displays the parent directory's contents (list)
cd ..
Goes to the parent directory (back button) (change directory)
rmdir new_directory
Removes directory named new_directory
**The up arrow copies the previous function into the command line
9/2/18
ls -Cx /directory/location
lists information about files within the given direction (done by ls) that also lists entries by columns (C) but then lists lines instead of columns (x) -- a double transformation.
ls -l /directiory/location
Displays long form format of directory's file names.
whoami
Displays the user's account -- whether it is standard or root.
~
9/12/18
Equal to the home directory (for example ls ~ gives the directories within the home directory which in this case is cms-opendata)
find /usr –name “*g++*” –print
finds all files within usr that has an extention (*) of g++ and print them to the terminal
which g++
Displays the full file path of commands that are g++ in nature.
**Tapping tab before entering the line into the terminal**
Auto-completes the file name if it is the only file within the directory that has those starting letters
echo
Displays text after the echo (or equivalent text if it is a universally special character such as ~)
.
Displays/does stuff to current directory -- often redundant
touch
Updates the access and modification times of each file that follows the touch command. If the file does not exist, it will make a new plain text document in its name
find . -name "*filename"
Finds a file (find) within the current directory (.) that has the segment "filename" at the end of its name. It can have anything before the "filename".
rm filename
Removes the file "filename"
cat
(Concatenate) If preceding a single function, this command is used to output the contents of a file. If it is used in series with many files, it can combine the contents of the files into a new file.
THIS IS THE TODO SECTION OF HW2 NOW
The 'touch' command is a command that is typically followed by a file name. If a file with that file name does not exist within the given directory, it will be created as a plain text document within the current directory. If it does exist, the metadata of the file's time of access and modification of that file will be updated to the current date and time.
The period after the find commands specifies on which directory the file command should be executed. Because the period refers to the current directory, the file command operates on the current directory.
The * character basically denotes the fact that anything can exist in place of the asterisk. In the instance of using it with the find command, it is a way of searching for a specific part of a file name but not caring what the other parts of the file name are.
The "rm" command precedes the filename of any file in the current directory that the user would like removed. It is different from the rmdir because the rmdir command removes a directory from the file manager, while rm removes an actual file within a given directory.
(Ironically, I actually played around with rm * in a test directory before even reading this question because I had amassed many junk files that I wanted to get rid of and I figured it might do the trick. Turns out I was right) The rm * is a command that removes all the files in a given directory. This occurs because the * could be filled with any file name in the directory so the rm command is processioned on every file.
Just a part of my sequence of messing around with rm, touch, rmdir, and *
From the set of code above it seems as if the > command inputs the output of the command that precedes it into the file that follows it. In the process, this function appears to delete whatever text was already in the file. In contrast, the >> command input the output of the command that precedes it into the file that follows it without replacing the text that already appears within it.
A danger of the > operator is that it could accidentally delete a large portion of text in a single command line.
I would expect to see the long form of all the objects within the current directory to be inserted into the log.txt file. The second command line would simply output the text that was just stored in the log.txt file (the objects in the current directory).
su
Switch to the root user ("super user") which allows one to execute even more powerful and more core commands. This command should be used with care as the super user has the power to ruin the system in a single terminal line
sudo
("Super user do") Allows the user to execute a command that is normally reserved for the super user without officially changing accounts via the su command.
history
Prints the numbered history of executed commands to the terminal.
cp
Copy a file from one directory to another directory.
mv
Moves a file from one directory to another directory
grep "sample_text" file_directory
Searches for the "sample_text" in file_directory
sed -i 's/originaltext/newtext/g' file_name
(Stream editor) Replaces original text with new text in every instance of its occurrence.
whereis
Displays where a specific command exists
whatis
Displays a short description of what a given command does (in this way it is similar, but less informative/overwhelming, to --help)
locate
Finds any file that contains the characters that follows the locate command and displays the directory tree for it (*note that the updatedb command which updates the database from which locate draws is typically set to update once a day, so in order to locate new files, the updatedb command must be run first to update the requisite database).
emacs -nw test.txt
Opens emacs (no window) with a new file named test.txt
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9/25/18
tcsh
Executes a program in the C shell ecosystem, allowing program modifications and execution from the terminal. The C shell can input text files as code to the compiler.
#!/bin/tcsh
# here we can put some comments
# this is a trivial script but can serve as an example
# a script can take inputs. These are assigned variable names $1, $2 etc
# based on their position
# here we create an environmental variable ARG and assign to it the value of the first input
set ARG=$1
# here as a bug statement we echo out the value to the screen
echo $ARG
# what is $ARG in double quotes
echo "$ARG"
# what is $ARG* in quotes
echo "$ARG*"
# how backticks (instead of quotes) change what we echo.
echo `ls / `
echo "check directory one level up"
echo `ls ../ `
echo "check the current directory"
echo `ls ./ `
# here we have it look for all the files in / and its subdirectories that
# contain somewhere in the file name the string we inputted
# you can change how wide or narrow your search is by changing / with ./ or ../ or /usr/
find /usr -name "*$ARG*" -print
This program above searches for the argument entered by the user after the script is called in any directory and then outputs each specific directory location to the terminal
chmod
"Change mode" -- (for this specific case it made it so that program can be run without specifying the tcsh command before the file location; it made it an executable)
Piping (executed using | symbol), is the act of having the output of one command funnel into (or pipe into) the input of a second function within the same line in the terminal.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
10/2/18
HW 4
Variables:
Number operations:
Non-numeric Variables
Loops 1:
Loops 2:
Loops 3:
HW 5 logbook -- 10/13/18:
Logic Statements:
Pointers 1:
Program 1:
Program 2:
Pointers 2:
Output for all the above functions:
The program the homework asked me to craft before the pink section (Pointer 3):
Output:
grep
"Globally search for regular expression" -- gets files that have a specific pattern (the pattern that follows the grep command, be it a date or a name etc etc)
10/20/18
ofstream
Outputs a stream class so that it can operate on files
ifstream
Takes in a stream class and allows it to be operated on by files.
Great resource:
https://www.cs.bu.edu/teaching/cs111/spring-2000/file-io/
10/27/18
Arrays in C++:
Random number generator with histogram:
\
11/4/18
Mass histogram after terminal and root commands. Peaks indicate the mass of the most commonly produced particles.
11/11/14
Sample event (angled so that certain particle tracks are easier to see)
XY plane view of the same event: