Posts

Showing posts from August, 2011

Delete

sed '5d' Delete line 5 sed '/[Tt]est/d' Delete all lines containing Test or test sed 's/...//' data Delete the first three characters from each line of data   sed 's/...$//' data Delete the last 3 characters from each line of data Delete all occurrences of a pattern in a file using sed command This is a simple application of the /s flag where the target string is none. For example, to remove all occurrences of word "line" in the above file, the sed command would be bash-3.00# sed 's/line//' textfile.txt This is 1 This is 2 This is 3 This is 4 This is 5 Note that the word to be replaced upon matching the pattern is none in the above command ('/s/line//') To remove all occurrences of the character space in the above input file, the sed command would be bash-3.00# sed 's/ //g' textfile.txt Thisisline1 Thisisline2 Thisisline3 Thisisline4 Thisisline5 Also note that if you don't use single quotes in the above s...

Definitions

Definitions These definitions are used throughout the remainder of this manual. POSIX A family of open system standards based on Unix. Bash is primarily concerned with the Shell and Utilities portion of the  posix  1003.1 standard.  blank A space or tab character.  builtin A command that is implemented internally by the shell itself, rather than by an executable program somewhere in the file system.  control operator A  token  that performs a control function. It is a  newline  or one of the following: ‘ || ’, ‘ && ’, ‘ & ’, ‘ ; ’, ‘ ;; ’, ‘ | ’, ‘ |& ’, ‘ ( ’, or ‘ ) ’.  exit status The value returned by a command to its caller. The value is restricted to eight bits, so the maximum value is 255.  field A unit of text that is the result of one of the shell expansions. After expansion, when executing a command, the resulting fields are used as the command name and arguments.  filename ...