Pages

Linux Mint using tar to backup and compress folders

tar -czvf archivefilename.tar.gz foldername1 foldername2


-c: Create
-z: Compress
-v: Display progress
-f: Name of the archive.

Editing Linux Mint 'Places'

vim .config/gtk-3.0/bookmarks

Delete files recursively

To delete files of the specified name/pattern from current directory and all sub directories.

find . -type f -name 'myfilename' -exec rm {} +

Make a file executable

To make a file executable and runnable by any user:

chmod a+x myfilename

grep search source code for specific string(s)

I had limited success incorporating this grep command into a bash script so I've documented it here so I can easily cut n' paste it in the future.

egrep -R -H -n -C1 --include=*.c --include=*.h 'searchstring'

If the search string contains spaces you need to use \s+ between the terms.

If the search string contains regex special characters they have to be escaped.

For example to search for "char *actual" the full search string becomes:

egrep -R -H -n -C1 --include=*.c --include=*.h 'char\s+\*actual'

Options:
-R to recurse
-H to show the file names
-n to show the line numbers
-C1 to show one line either side of the found line for context

Visual Studio Code Solution creation on Linux Mint

Creating a C# based Solution in Visual Studio Code on Linux isn't as straightforward as using the full version of Visual Studio 2017 on Windows.

The steps below detail how to create a Solution with a Console project and an MSTest project for Unit Testing.

Create a folder for the whole solution and create the solution (mySolution):
mkdir mySolution
cd mySolution
dotnet new sln
Create a folder for the main project, then create the main project (myProject):
mkdir myProject
cd myProject
dotnet new console
Create a folder for the test project, then create the test project (myTests):
cd ..
mkdir myTests
cd myTests
dotnet new mstest
Switch back to the solution folder and add the main project and test project into the solution file (mySolution.sln, myProject.csproj, myTests.csproj):
cd ..
dotnet sln mySolution.sln add myProject/myProject.csproj myTests/myTests.csproj
Switch to the tests project folder and add a Reference to the main project (myTests, myProject):
cd myTests
dotnet add reference ../myProject/myProject.csproj
Switch back to the solution folder and run the tests (myTests):
cd ..
dotnet test myTests/myTests.csproj

Open the mySolution folder in Visual Studio Code and the Explorer view should look like this:


And in Bash script form:
#!/bin/sh
#$1 is the solution name
#$2 is the main project name
#$3 is the main project type e.g. console, classlib, web etc.

echo "Create a folder for the whole solution and create the solution"
mkdir $1
cd $1
dotnet new sln

echo "Create a folder for the main project, then create the main project"
mkdir $2
cd $2
dotnet new $3

echo "Create a folder for the test project, then create the test project"
cd ..
mkdir $2Tests
cd $2Tests
dotnet new mstest

echo "Switch back to the solution folder and add the main project and test project into the solution file"
cd ..
dotnet sln $1.sln add $2/$2.csproj $2Tests/$2Tests.csproj

echo "Switch to the tests project folder and add a Reference to the main project"
cd $2Tests
dotnet add reference ../$2/$2.csproj

echo "Switch back to the solution folder and run the tests"
cd ..
dotnet test $2Tests/$2Tests.csproj

For example:
./CreateVsCodeSolution.sh mySol2 myProj2 console

will create this solution:

Git and GitHub

GitHub

Fork the original repository

Git

git clone https://github.com/MY_USERNAME/MY_FORK.git
git checkout DEVELOPMENT_BRANCHNAME
git branch
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
git remote -v

git push -u origin DEVELOPMENT_BRANCHNAME
git fetch upstream

git --version
git config --list
git config --global credential.helper wincred

Remove file from git without deleting file

git rm --cached filename