user:nreitter:start
Rejoining class chat Most of you probably already know this but I thought I would throw it on here for quick reference. So to join a class chat session do:
$screen irssi /server irc /join nameOfYourCouse
Using vi/vim
- This is not classic vi it's vim.
- The esc key will get you back to command mode.
- vi - is a moded text editor
- command: symbols are commands
- input: symbols are input
- i this will put you into input mode. (This will place characters before the courser.
- a this will insert after the courser.
- I this will insert at the beginning of the line
- A this will insert at the end of a the line.
- o this will start on the next line.
- O this will start you on the line before.
- Navigation
- h go left
- l go right
- j down
- k up
- w right by word
- b left by word
- {} these jump up and down by stanza
- Manipulation
- X remove character left (cut)
- x remove character right (cut)
- p place to the left of cursor (paste)
- P place to the right of cursor (paste)
- . this will run the last command
- How to save from vi - in command mode hit : then w then fileName (:w myFile)
- How to leave the vi text editor
- :wq - save and quit
- :w - name save as
- :q - quit
- :q! - with without saving
Viewing files in a directory with Wildcards
- ls -a - This will list hidden files. If you use the -A this will remove the extra information.
- ls -1 - This will list the files that a normal ls would give you but it will list them with one file per line.
- ls -1 ???? - This will list only the files in your current directory that have 4 characters. Similarly if you use 5 ?s it would list the files with 5 characters.
- ls | wc -l - The wc -l part of the command counts the entries.
- ls -1 c??? - This will give all the 4 character files that begin with c. If you wanted to see the ones with uppercase C as well you can use a character class like : [cC]???
- ls -1 ?[aeiou]?[aeiou]? - This command looks very complicated but it is simply giving us the 5 character file names which have vowels in the 2nd and 4th character place.
- ls -1 ????* - This shows the files which have 4 or more characters.
- ls -1 *p - This will show all the files that begin with “p”
- ls -1 *hi* - This searches for any and all files that have the characters “hi” in them.
- file * - This command will show the file information for every in the current directory.
Wildcards
- * - match 0 or more of anything.
- ? - match exactly 1 of anything.
- [] - Character class match any 1 of the enclosed
- [^ ] - inverted characters class, do not match any 1 of enclosed.
- If it accepts a file you can use a wild card in its place.
Some basic scripting stuff and cool commands…
* If you would like to use a command but need to have a “-something” the “-” would make the command try and use “something” as an argument. So if you need to have a “-” in something you need in a command you can use – to negate the later “-”. An example of this: grep -q – '-greppingForThis'
- If you want to print out the debugging information for a file you use the #!/bin/bash -x we all probably know this. But if you would like to add it as a argument to your script you can use: set -o xtrace
- If you want to know the width of the screen your running on (or in a script) use tput cols. The best way to use this (at least in a script) is probably to set it in a variable like this: var=$(tput cols) Then when you call the function it will come back with the screen width.
- A cool thing: If you want an error your printing to standard standard error just redirect standard input into standard error by doing 1>&2
- « If you want to compose a file on the command line do:
$ cat <<name >stuff here. >More things. >name
- A couple notes: whatever you put after the “«” in this case “name” also needs to end the command line (see above).
- This is called a “here file”
- «< - a “here string.” This will simply basically echo what comes after like:
$ cat <<< "Stuff" Stuff
- When doing a “exit” you can add an exit code like: exit 0 This is the one we usually use but if you do an exit 1 (or any other number). That tells the script to exit with a “1” This is really helpful when debugging and if you would like to view the exit code do “$?” on the command line..
- Something cool. If you would like to see your command history do: history
- Then along the left side you can see the “history” number. You can use those numbers to call back specific commands. Like:
... 550 echo "hello" 551 echo "$test" $ !550 hello
user/nreitter/start.txt · Last modified: 2018/04/09 15:23 by nreitter