How Do You Create a PowerShell Script to Filter a List by Removing Any Line That Matches Patterns or Strings in a Second File?

Problem scenario
You have two files.  One file is the main file you want to modify by removing lines that match specific patterns.  The second file has patterns (or strings) that should not be in a final, filtered list.   How do you filter a file to remove the patterns that match strings in another file?

Solution
# This assumes you want to ignore blank spaces in the second file.  

How Do You Troubleshoot a PowerShell Error “CreateFromDirectory … The Path Is Not of a Legal Form”?

Problem scenario
You want a PowerShell script to place files from a folder into one zip file.

When using PowerShell version 3, your script throws this error:


Exception calling “CreateFromDirectory” with “2” argument(s): “The path is not of a legal form.”
At line…
     CategoryInfo                  : NotSpecified: (:) [], MethodInvocationException
   

How Do You Troubleshoot a C++ Program That Will Not Compile Due to Undefined Reference Errors?

Problem scenario: You try to compile a C++ program with gcc, but you get this output:

/tmp/ccj6eKDl.o: In function `main’:
q.cpp:(.text+0x14): undefined reference to `std::cout’
q.cpp:(.text+0x19): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’
q.cpp:(.text+0x28): undefined reference to `std::cout’
q.cpp:(.text+0x2d): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)’
/tmp/ccj6eKDl.o: In function `__static_initialization_and_destruction_0(int,

How Do You Compile a C++ Program When You Get “Gcc: Error Trying to Exec ‘cc1plus’: Execvp: No Such File or Directory”?

Problem scenario:  When trying to compile a C++ program (e.g., $ gcc hello.cpp), you receive this error:
“gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory”

What do you do?

Solution
Install gcc-c++.  For a RedHat distribution of Linux, use this command:

yum -y install gcc-c++

How Do You Write a C Program to Writes Hexadecimal Numbers 1 Through F Each on New Lines of a New File?

Problem scenario:  Using the C programming language, you want to write a program that produces a file (we’ll call it contint.txt) that has the following content:

1
2
3
4
5
6
7
8
9
a
b
c
d
e
f

Solution
Overview of the approach:  Hexadecimal numbers use base 16. 

Using PowerShell Version 3, How Do You Determine If a Port Is Open for a given IP Address?

Problem scenario
You are using Windows 7 and PowerShell version 3.  You want to test if a port is open to a given IP address.  (If you are using a modern version of PowerShell, use the Test-NetConnection command.)   How do you find out if a port of an IP address is open or not?

Solution
Use the PowerShell function Test-TCPPortConnection written by Jonathan Medd.  

How Do You Download a File With PowerShell When You Get the Error “Not enough space on disk”?

Problem scenario
You are using PowerShell 3.0 on Windows 7 and you try to run the PowerShell command start-bitstransfer to download a large file.  Running start-bitstransfer results in an error that says “Not Enough space on disk.” 

Solution
Verify the size of the file.  See if the destination directory/drive has sufficient space.  If this error happens despite there being ample space available in the destination drive and destination directory compared to the size of the source media,