Skip to main content

Posts

Showing posts with the label script

Linux and Unix - Script and Screen

More for future me: script <filename> #This will basically start a file named whatever in thr location you specified with every command you entered. Once you are finished type Ctrl+D to stop recording the session and then you can go back and read your file. Keep in mind that script is not perfect and other cli based apps will get recorded too which may make your script output look a bit odd. Screen <option> #This is used when needing to switch or disconnect from multiple cli sessions. Using -list you can see all of the sessions, -r will allow you to reconnect to one and Ctrl+A and Quit will allow you to quit properly the session. If you only need to leave it temporarily using Ctrl+A and D which will just disconnect that screen session.

Linux and Unix - Script Building

Another dump of some information that i may need again in the future. Example Code: #!/bin/bash echo -e "What is your favorite color?" read choice echo "$choice is your favorite color." TLDR - Basically using read you can take text input. Echo will allow you echo is out to the prompt. You can also interact now with the variable $choice with other command such as grep or awk You can also use '-x' when executing your Bash Scripts to print it onscreen as it runs through in the event there is any errors or debugging needed.