Skip to content

Directory and packageprogram

Eric Flumerfelt edited this page Jun 17, 2022 · 1 revision

Directory and package/program

This is copied from cmd window in Linux virtual desktop.

> $ mkdir -p/TRACE_RPM/RPMFORTRACE
> $ cd/TRACE_RPM/RPMFORTRACE
> $ cat << EOF > RPMFORTRACE
> #!/bin/bash
> echo “Welcome to the amazing new TRACE RPM.”
> EOF
> $ chmod 644 RPMFORTRACE
> $ bash ./RPMFORTRACE
> Welcome to the amazing new TRACE RPM.

  • what is the purpose of the first two lines “mkdir -p ~/TRACE_RPM/RPMFORTRACE” and “cd ~/TRACE_RPM/RPMFORTRACE?” Couldn’t I just have written “mkdir RPMFORTRACE” and get the same result??
    • I deleted the original TRACE_RPM along with its contained RPMFORTRACE directory (I think) and double-checked that they were deleted with these commands:
      > $ cd
      > $ rm -r RPMFORTRACE
      > rm: cannot remove ‘RPMFORTRACE’: No such file or directory
      > $ rm -r TRACE_RPM
      > $ cd TRACE_RPM
      > bash: cd: TRACE_RPM: No such file or directory

Then, believing that the “-p ~/” symbols and the lines with “chmod 644” & “#!/bin/bash” weren’t required, I recreated the files with this set of commands:
> $ mkdir TRACE_RPM
> $ mkdir TRACE_RPM/RPMFORTRACE
> $ cd TRACE_RPM/RPMFORTRACE
> $ cat << EOF > RPMFORTRACE
> echo “Welcome to the amazing new TRACE RPM!”
> EOF
> $ bash ./RPMFORTRACE
> Welcome to the amazing new TRACE RPM!

In reality, doing it this way adds an extra line in the creation of the RPMFORTRACE directory. This can be easily seen by comparing the first 2-3 lines of each set of coding. So the shortest set of coding with the desired result should be as follows:
> $ mkdir -p/TRACE_RPM/RPMFORTRACE
> $ cd TRACE_RPM/RPMFORTRACE
> $ cat << EOF > RPMFORTRACE
> echo “Welcome to the amazing new TRACE RPM!”
> EOF
> $ bash ./RPMFORTRACE
> Welcome to the amazing new TRACE RPM!
Why do I want to create a file inside a directory inside a directory rather than one directory with a file? Is it just for the familiarization that I can change to the directory contained within another directory?

Clone this wiki locally