- The document provides a tutorial introduction to using the UNIX text editor ed. It discusses basic commands like append (a), write (w), quit (q), edit (e), and read (r) to create, modify, save, and open text files with ed.
- The append command (a) allows adding new text lines to the editor's buffer, while write (w) saves the buffer contents to a file. Edit (e) loads an entire file into the buffer, overwriting any existing contents, and read (r) loads a file without deleting the current buffer contents.
- The tutorial encourages readers to practice the commands by creating sample text files, and provides exercises to help learn how to use
Coding in Disaster Relief - Worksheet (Advanced)Charling Li
The document provides instructions for engineering students to code a Python program on a Raspberry Pi to broadcast a distress signal over radio frequencies and call for evacuation assistance before an approaching hurricane. It covers Python coding basics like print functions, variables, conditional statements, loops, importing libraries, custom functions, and using libraries to add delays. The students are guided to write code that imports the ewb library, starts a radio broadcast on a frequency, transmits a looping message with delays, and includes the date, time and location in the broadcast.
This document provides instructions on creating and using scripts in Linux. It discusses advantages of scripts like linking programs together and controlling programs non-interactively. It covers creating scripts by storing commands in a file, using the shebang line to specify the interpreter, and running scripts. It also explains variables, comments, debugging errors, arithmetic expressions using expr, reading user input with read, and provides exercises to write simple scripts.
Open mp library functions and environment variablesSuveeksha
The document discusses OpenMP library functions and environment variables. It provides examples of some of the most heavily used OpenMP library functions like omp_get_num_threads(), omp_set_num_threads(), and omp_get_thread_num(). It also lists some additional OpenMP library functions for initializing, destroying, setting, and testing simple locks. An example code shows how these functions can be used within an OpenMP parallel region to distribute a loop workload across threads. Finally, it discusses some common OpenMP environment variables for setting the schedule, number of threads, and enabling dynamic thread adjustment.
Microcontroladores: Programación en C para microcontroladores con AVR Butterf...SANTIAGO PABLO ALBERTO
This document discusses pointers and arrays in C. It begins by explaining how addresses were represented in early computers using switches, and how pointers represent memory locations. It then provides examples of defining pointer variables, assigning the addresses of other variables to pointers, dereferencing pointers, and using pointers to access array elements. The document notes that pointers allow passing arrays to functions more efficiently. It also discusses some common mistakes made with pointers regarding operator precedence and incrementing/dereferencing pointers. Finally, it shows examples of using pointers to iterate through character arrays, relating pointers to array subscripts.
This document introduces simple Java programming concepts through examples. It discusses how to write a basic "Hello World" program in Java and shows a program that generates simple sentences by randomly choosing words from text files. It also describes common types of errors that can occur in programs and explains the basic process of compiling and executing a Java program.
Programming involves using assembly language as the common language between the programmer and microcontroller. Assembly language is translated into machine language (binary) by an assembler. Basic elements of assembly language include labels, instructions, operands, directives, and comments. Assembly language programs define parameters like the oscillator type and use directives like _CONFIG to set configuration bits before writing the code. Control directives like IF, WHILE, and FOR are used for conditional programming.
- The document discusses various text editing and file transfer tools available in Unix systems including Emacs, vi, FTP, pine, and lpr. It focuses on using Emacs as a text editor, including how to open and save files, navigate text, and get help. It also covers using FTP and pine to transfer files between systems and access email from within Unix.
Coding in Disaster Relief - Worksheet (Advanced)Charling Li
The document provides instructions for engineering students to code a Python program on a Raspberry Pi to broadcast a distress signal over radio frequencies and call for evacuation assistance before an approaching hurricane. It covers Python coding basics like print functions, variables, conditional statements, loops, importing libraries, custom functions, and using libraries to add delays. The students are guided to write code that imports the ewb library, starts a radio broadcast on a frequency, transmits a looping message with delays, and includes the date, time and location in the broadcast.
This document provides instructions on creating and using scripts in Linux. It discusses advantages of scripts like linking programs together and controlling programs non-interactively. It covers creating scripts by storing commands in a file, using the shebang line to specify the interpreter, and running scripts. It also explains variables, comments, debugging errors, arithmetic expressions using expr, reading user input with read, and provides exercises to write simple scripts.
Open mp library functions and environment variablesSuveeksha
The document discusses OpenMP library functions and environment variables. It provides examples of some of the most heavily used OpenMP library functions like omp_get_num_threads(), omp_set_num_threads(), and omp_get_thread_num(). It also lists some additional OpenMP library functions for initializing, destroying, setting, and testing simple locks. An example code shows how these functions can be used within an OpenMP parallel region to distribute a loop workload across threads. Finally, it discusses some common OpenMP environment variables for setting the schedule, number of threads, and enabling dynamic thread adjustment.
Microcontroladores: Programación en C para microcontroladores con AVR Butterf...SANTIAGO PABLO ALBERTO
This document discusses pointers and arrays in C. It begins by explaining how addresses were represented in early computers using switches, and how pointers represent memory locations. It then provides examples of defining pointer variables, assigning the addresses of other variables to pointers, dereferencing pointers, and using pointers to access array elements. The document notes that pointers allow passing arrays to functions more efficiently. It also discusses some common mistakes made with pointers regarding operator precedence and incrementing/dereferencing pointers. Finally, it shows examples of using pointers to iterate through character arrays, relating pointers to array subscripts.
This document introduces simple Java programming concepts through examples. It discusses how to write a basic "Hello World" program in Java and shows a program that generates simple sentences by randomly choosing words from text files. It also describes common types of errors that can occur in programs and explains the basic process of compiling and executing a Java program.
Programming involves using assembly language as the common language between the programmer and microcontroller. Assembly language is translated into machine language (binary) by an assembler. Basic elements of assembly language include labels, instructions, operands, directives, and comments. Assembly language programs define parameters like the oscillator type and use directives like _CONFIG to set configuration bits before writing the code. Control directives like IF, WHILE, and FOR are used for conditional programming.
- The document discusses various text editing and file transfer tools available in Unix systems including Emacs, vi, FTP, pine, and lpr. It focuses on using Emacs as a text editor, including how to open and save files, navigate text, and get help. It also covers using FTP and pine to transfer files between systems and access email from within Unix.
This document provides an overview of tools for effective data manipulation including GNU Emacs, the BASH shell, and Ruby. It discusses how GNU Emacs can be used for powerful text editing and file manipulation through keyboard macros and mode-specific commands. The BASH shell and variables are summarized as useful for file manipulation and applying UNIX commands. Ruby is presented as a scripting language well-suited for directly processing file contents, with an example provided to select and rearrange fields from a comma-separated file. References for further learning about these tools are also listed.
This document provides an overview of tools for effective data manipulation including GNU Emacs, the BASH shell, and Ruby. It discusses how GNU Emacs can be used for powerful text editing and file manipulation through keyboard macros and mode-specific commands. The BASH shell and variables are summarized as useful for file manipulation and applying UNIX commands. Ruby is presented as a scripting language well-suited for directly processing file contents, with an example provided to select and rearrange fields from a comma-separated file. References for further learning about these tools are also listed.
This document provides an intermediate-level practical guide to using Unix. It covers topics such as redirecting standard input/output to files, filename substitution using wildcards, using shell variables, command substitution, and writing simple shell scripts. Examples are provided to illustrate how to use commands like date, ls, and echo to manipulate files and data. Shell programming concepts like conditional expressions and foreach loops are demonstrated in short scripts.
The document discusses shells and shell programming. It provides information on:
- Shells provide an interface to run commands and programs and display outputs. Common shells include Bourne, C, and other derivative shells.
- Shells prompt for commands and interpret them, passing commands to the kernel for execution and displaying outputs.
- Shell scripts allow automated execution of commands through programming constructs like variables, conditionals, loops, and functions.
The document discusses shells and shell programming. It provides information on:
- Shells provide an interface to run commands and programs and display outputs. Common shells include Bourne, C, and other derivative shells.
- Shells prompt for commands and interpret them, passing commands to the kernel for execution and displaying outputs.
- Shell scripts allow automated execution of commands through programming constructs like variables, conditionals, loops, and functions.
The document provides information about shells in Linux operating systems. It defines what a kernel and shell are, explains why shells are used, describes different types of shells, and provides examples of shell scripting. The key points are:
- The kernel manages system resources and acts as an intermediary between hardware and software. A shell is a program that takes commands and runs them, providing an interface between the user and operating system.
- Shells are useful for automating tasks, combining commands to create new ones, and adding functionality to the operating system. Common shells include Bash, Bourne, C, Korn, and Tcsh.
- Shell scripts allow storing commands in files to automate tasks.
Linux is an open-source alternative to Microsoft Windows that is freely available and reliable. It has a command line interface and features like virtual memory, networking capabilities, multiple users, and graphical user interfaces. Common Linux commands include ls, cd, mkdir, rmdir, cat, cp, and editors like vi, emacs, nano are used to create and edit files. The Linux directory structure is hierarchical with key directories being /, /home, /usr, /var, and editors allow editing files in different modes like insert and command modes.
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
Article link: http://iveybusinessjournal.com/publication/managing-global-risk-to-seize-competitive-advantage/
Requirements: Write one summary and study note both no longer than one pages should include all point of article. Then do a PPT and write a presenting paper only for 5 minutes.
Groups of students will create and offer two MS PowerPoint presentation summarizing the main points of one of the readings for this course along with a one page handout for the students in the class. The aim of the presentations and the handouts is to provide the audience with the main ideas of the article and study notes. Groups will bring to class enough copies of the handout for each student in the class. The handout should list the name of the author, the title of the article, the title of the journal, and the publication date and page numbers along with a summary of its main points. Please do not exceed one page for this material.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* Read a .dat file and reverse it.
*/
public class Reverse {
public static void main(String[]args) {
if (args.length != 3) {
System.err.println(" Incorrect number of arguments");
System.err.println(" Usage: ");
System.err.
println("\tjava Reverse <stack type> <input file> <output file>");
System.exit(1);
}
boolean useList = true;
if (args[0].compareTo("list")==0)
useList = true;
else if (args[0].compareTo("array")==0)
useList = false;
else {
System.err.println("\tSaw "+args[0]+" instead of list or array as first argument");
System.exit(1);
}
try {
//
// Set up the input file to read, and the output file to write to
//
BufferedReader fileIn =
new BufferedReader(new FileReader(args[1]));
PrintWriter fileOut =
new PrintWriter(new
BufferedWriter(new FileWriter(args[2])));
//
// Read the first line of the .dat file to get sample rate.
// We want to store the sample rate value in a variable,
// but we can ignore the "; Sample Rate" part of the line.
// Step through the first line one token (word) at a time
// using the StringTokenizer. The fourth token is the one
// we want (the sample rate).
//
StringTokenizer str;
String oneLine;
int sampleRate;
String strJunk;
oneLine = fileIn.readLine();
str = new StringTokenizer(oneLine);
strJunk = str.nextToken(); // Read in semicolon
strJunk = str.nextToken(); // Read in "Sample"
strJunk = str.nextToken(); // Read in "Rate"
// ...
This document provides an introduction and overview of LaTeX. It discusses the basic structure of a LaTeX document including the preamble, body, and back matter. It describes LaTeX input files as plain text files that can be edited in any text editor. The document structure typically includes a title page, abstract, main content divided into sections and subsections, and bibliography. Numbering and formatting of section headings is automatic in LaTeX. The document serves as an online tutorial for LaTeX basics.
This document provides a LaTeX tutorial for beginners. It introduces LaTeX as a typesetting program that formats text into lines, paragraphs and pages. The tutorial demonstrates how to create a simple LaTeX document that typesets text in italics and prints the current date. It explains that LaTeX allows users to beautifully typeset technical documents, especially those containing mathematics, which can be difficult in word processors. The document serves as a primer to teach basic LaTeX commands and formatting.
This document provides a LaTeX tutorial intended as a primer for new LaTeX users. It begins with an overview of what LaTeX is and how it differs from word processors. LaTeX is described as a typesetting program concerned with formatting text into lines, paragraphs and pages, whereas word processors integrate additional functions. The document then demonstrates some basic LaTeX commands through a simple example document. It explains the use of the \documentclass, \begin{document}, and \end{document} commands as well as commands like \emph and \LaTeX to produce italics and the LaTeX name. This introduction aims to illustrate the core features of LaTeX and how text and commands are combined in a LaTeX source file to produce formatted output.
Part 4 Scripting and Virtualization (due Week 7)Objectives1. .docxkarlhennesey
Part 4: Scripting and Virtualization (due Week 7)Objectives
1. To learn scripting on Windows and Linux
2. To add virtualization with a Linux distributionStepsPart 1—Windows Scripting
Basic Script: Scripting is useful for small programming projects or quick tasks. Often, these programs are short and meant for small problems. Unlike compiled programming languages, scripting languages are generally interpreted. Batch files or scripts are created to automate tasks and may contain several commands in one file. Scripts can be created in Notepad. These are short files that run each command in sequence at file execution. The windows command-line interface can be used to run scripts.
Below are some commands.
Echo = Displays a message in the batch file
Echo. displays a blank line
@command turns off the display of the current command
@echo off = does not echo back text
cls = clears your screen
:: = Adds comments to your code; this line will not be displayed
Start = used to start a windows application
Creating a Basic Script
cls
@echo off
::Your Name
echo "Creating a data dump file"
ipconfig /all > C:\Scripts\config_info.txt
echo end of script
Open Notepad by going to Start-> All Programs -> Accessories-> Notepad.
Type the above script into Notepad.
Create a directory named Scripts on the C:\ drive. Save this file in the C:\Scripts folder as myscript.cmd.
Do not close your Notepad file. To run, open a command prompt by typing cmd in the Search Programs and Files box when you click the Start button or search for cmd.
Change directory to the C:\Scripts folder by typing the following.
cd c:\Scripts
Then type in the following.
myscript.cmd
The script should run and will create a file.
Use the dir command to see what files are created.
Keep both the Notepad file and the command prompt open for the next step.
You can also shut down a computer from a script. This is helpful for remote shutdown in a networking situation. Add the following commands to your script and save it in Notepad. (Note: The ping command, though normally used for networking, here waits 4 seconds.)
shutdown /s /t 60 /c "Local shutdown in 1 minute!"
ping -w 1000 0.0.0.0 > nul
shutdown /a
echo "Shutdown has been aborted"
Click back to the command prompt.
Type in myscript.cmd to run the script.
You should see the script attempt to shut down, then abort the shutdown.
Keep both your Notepad and command prompt open.
Environment variables are built-in system variables available for all Windows processes describing users, paths, and so on.
Some common environment variables are as follows.
%PATH% = contains a list of directories with executable files, separated by semicolons. To add a path:
SET PATH = %PATH%;C:\Windows\Eclipse
%DATE% and %TIME% = current date and time
%RANDOM% = returns a random number between 0 and 32767
%WINDIR% = points to the windows directory C:\Windows
%PATHEXT% = displays executable file extensions ie .com, .exe, .bat, .cmd, .vbs, .vbe, ...
The document provides an introduction to C++ programming including setting up a compiler, the structure of a basic C++ program, variables, and input/output. It explains that a compiler is needed to convert C++ code into an executable. The main() function is called at startup and returns an integer value. A basic "Hello World" program is shown using #include, cout, and cin.get(). Variables are declared with a data type like int or char and stored user input. Comments are added using // or /* */.
This document provides information about various Linux commands. It begins by defining what a command is and explaining the different types of commands - built-in shell commands and external commands. It then discusses command navigation shortcuts and various file manipulation commands like mkdir, rmdir, touch, cp, rm, man, head, tail, cat, tac, more and files. The document also covers the Linux filesystem hierarchy standard and describes the main directories for binaries, configuration, data and memory. Overall, the document serves as a guide to common Linux commands and filesystem structure.
This document provides a tutorial on Unix shell scripting. It begins with an introduction to shell scripting and why it is useful for automating tasks. It then discusses the shell scripting environment in Unix. The bulk of the document covers shell scripting basics like command redirection, variables, control structures like if/then statements and loops. It provides examples of how to use variables, command line arguments, arithmetic expansion, and other shell scripting elements to automate tasks in Unix.
This document provides an introduction and overview of UNIX shell scripting. It discusses the benefits of scripting to automate repetitive tasks and make ones work at the shell easier. It then covers various topics related to shell scripting including the UNIX environment, different shells available for scripting, basics of shell scripting like variables, command line arguments, control structures, and more. The document is intended to provide a good starting point for understanding shell scripting in UNIX.
The document discusses various shell and command line tools to improve productivity for developers, including:
- Bash basics like keyboard navigation, piping, I/O redirection
- Tools like GNU Screen for multitasking and Vim for text editing
- Phing for project automation and deployment
- Benchmarking tools like Apache Bench and Siege
It provides examples of using these tools and resources for further learning shell scripting and command line skills. The overall agenda is around becoming a more efficient "Bash Ninja" through mastering the shell environment.
This document provides a cheat sheet of common Linux commands and their usage. It covers basic file operations like copying, moving, deleting files and directories. It also includes commands for viewing files, compressing/decompressing files, finding files, remote access, and getting system information. The commands are explained over 3 pages with examples of proper syntax and usage for each one.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
More Related Content
Similar to A tutorial introduction to the unix text editor ed
This document provides an overview of tools for effective data manipulation including GNU Emacs, the BASH shell, and Ruby. It discusses how GNU Emacs can be used for powerful text editing and file manipulation through keyboard macros and mode-specific commands. The BASH shell and variables are summarized as useful for file manipulation and applying UNIX commands. Ruby is presented as a scripting language well-suited for directly processing file contents, with an example provided to select and rearrange fields from a comma-separated file. References for further learning about these tools are also listed.
This document provides an overview of tools for effective data manipulation including GNU Emacs, the BASH shell, and Ruby. It discusses how GNU Emacs can be used for powerful text editing and file manipulation through keyboard macros and mode-specific commands. The BASH shell and variables are summarized as useful for file manipulation and applying UNIX commands. Ruby is presented as a scripting language well-suited for directly processing file contents, with an example provided to select and rearrange fields from a comma-separated file. References for further learning about these tools are also listed.
This document provides an intermediate-level practical guide to using Unix. It covers topics such as redirecting standard input/output to files, filename substitution using wildcards, using shell variables, command substitution, and writing simple shell scripts. Examples are provided to illustrate how to use commands like date, ls, and echo to manipulate files and data. Shell programming concepts like conditional expressions and foreach loops are demonstrated in short scripts.
The document discusses shells and shell programming. It provides information on:
- Shells provide an interface to run commands and programs and display outputs. Common shells include Bourne, C, and other derivative shells.
- Shells prompt for commands and interpret them, passing commands to the kernel for execution and displaying outputs.
- Shell scripts allow automated execution of commands through programming constructs like variables, conditionals, loops, and functions.
The document discusses shells and shell programming. It provides information on:
- Shells provide an interface to run commands and programs and display outputs. Common shells include Bourne, C, and other derivative shells.
- Shells prompt for commands and interpret them, passing commands to the kernel for execution and displaying outputs.
- Shell scripts allow automated execution of commands through programming constructs like variables, conditionals, loops, and functions.
The document provides information about shells in Linux operating systems. It defines what a kernel and shell are, explains why shells are used, describes different types of shells, and provides examples of shell scripting. The key points are:
- The kernel manages system resources and acts as an intermediary between hardware and software. A shell is a program that takes commands and runs them, providing an interface between the user and operating system.
- Shells are useful for automating tasks, combining commands to create new ones, and adding functionality to the operating system. Common shells include Bash, Bourne, C, Korn, and Tcsh.
- Shell scripts allow storing commands in files to automate tasks.
Linux is an open-source alternative to Microsoft Windows that is freely available and reliable. It has a command line interface and features like virtual memory, networking capabilities, multiple users, and graphical user interfaces. Common Linux commands include ls, cd, mkdir, rmdir, cat, cp, and editors like vi, emacs, nano are used to create and edit files. The Linux directory structure is hierarchical with key directories being /, /home, /usr, /var, and editors allow editing files in different modes like insert and command modes.
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
Article link: http://iveybusinessjournal.com/publication/managing-global-risk-to-seize-competitive-advantage/
Requirements: Write one summary and study note both no longer than one pages should include all point of article. Then do a PPT and write a presenting paper only for 5 minutes.
Groups of students will create and offer two MS PowerPoint presentation summarizing the main points of one of the readings for this course along with a one page handout for the students in the class. The aim of the presentations and the handouts is to provide the audience with the main ideas of the article and study notes. Groups will bring to class enough copies of the handout for each student in the class. The handout should list the name of the author, the title of the article, the title of the journal, and the publication date and page numbers along with a summary of its main points. Please do not exceed one page for this material.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* Read a .dat file and reverse it.
*/
public class Reverse {
public static void main(String[]args) {
if (args.length != 3) {
System.err.println(" Incorrect number of arguments");
System.err.println(" Usage: ");
System.err.
println("\tjava Reverse <stack type> <input file> <output file>");
System.exit(1);
}
boolean useList = true;
if (args[0].compareTo("list")==0)
useList = true;
else if (args[0].compareTo("array")==0)
useList = false;
else {
System.err.println("\tSaw "+args[0]+" instead of list or array as first argument");
System.exit(1);
}
try {
//
// Set up the input file to read, and the output file to write to
//
BufferedReader fileIn =
new BufferedReader(new FileReader(args[1]));
PrintWriter fileOut =
new PrintWriter(new
BufferedWriter(new FileWriter(args[2])));
//
// Read the first line of the .dat file to get sample rate.
// We want to store the sample rate value in a variable,
// but we can ignore the "; Sample Rate" part of the line.
// Step through the first line one token (word) at a time
// using the StringTokenizer. The fourth token is the one
// we want (the sample rate).
//
StringTokenizer str;
String oneLine;
int sampleRate;
String strJunk;
oneLine = fileIn.readLine();
str = new StringTokenizer(oneLine);
strJunk = str.nextToken(); // Read in semicolon
strJunk = str.nextToken(); // Read in "Sample"
strJunk = str.nextToken(); // Read in "Rate"
// ...
This document provides an introduction and overview of LaTeX. It discusses the basic structure of a LaTeX document including the preamble, body, and back matter. It describes LaTeX input files as plain text files that can be edited in any text editor. The document structure typically includes a title page, abstract, main content divided into sections and subsections, and bibliography. Numbering and formatting of section headings is automatic in LaTeX. The document serves as an online tutorial for LaTeX basics.
This document provides a LaTeX tutorial for beginners. It introduces LaTeX as a typesetting program that formats text into lines, paragraphs and pages. The tutorial demonstrates how to create a simple LaTeX document that typesets text in italics and prints the current date. It explains that LaTeX allows users to beautifully typeset technical documents, especially those containing mathematics, which can be difficult in word processors. The document serves as a primer to teach basic LaTeX commands and formatting.
This document provides a LaTeX tutorial intended as a primer for new LaTeX users. It begins with an overview of what LaTeX is and how it differs from word processors. LaTeX is described as a typesetting program concerned with formatting text into lines, paragraphs and pages, whereas word processors integrate additional functions. The document then demonstrates some basic LaTeX commands through a simple example document. It explains the use of the \documentclass, \begin{document}, and \end{document} commands as well as commands like \emph and \LaTeX to produce italics and the LaTeX name. This introduction aims to illustrate the core features of LaTeX and how text and commands are combined in a LaTeX source file to produce formatted output.
Part 4 Scripting and Virtualization (due Week 7)Objectives1. .docxkarlhennesey
Part 4: Scripting and Virtualization (due Week 7)Objectives
1. To learn scripting on Windows and Linux
2. To add virtualization with a Linux distributionStepsPart 1—Windows Scripting
Basic Script: Scripting is useful for small programming projects or quick tasks. Often, these programs are short and meant for small problems. Unlike compiled programming languages, scripting languages are generally interpreted. Batch files or scripts are created to automate tasks and may contain several commands in one file. Scripts can be created in Notepad. These are short files that run each command in sequence at file execution. The windows command-line interface can be used to run scripts.
Below are some commands.
Echo = Displays a message in the batch file
Echo. displays a blank line
@command turns off the display of the current command
@echo off = does not echo back text
cls = clears your screen
:: = Adds comments to your code; this line will not be displayed
Start = used to start a windows application
Creating a Basic Script
cls
@echo off
::Your Name
echo "Creating a data dump file"
ipconfig /all > C:\Scripts\config_info.txt
echo end of script
Open Notepad by going to Start-> All Programs -> Accessories-> Notepad.
Type the above script into Notepad.
Create a directory named Scripts on the C:\ drive. Save this file in the C:\Scripts folder as myscript.cmd.
Do not close your Notepad file. To run, open a command prompt by typing cmd in the Search Programs and Files box when you click the Start button or search for cmd.
Change directory to the C:\Scripts folder by typing the following.
cd c:\Scripts
Then type in the following.
myscript.cmd
The script should run and will create a file.
Use the dir command to see what files are created.
Keep both the Notepad file and the command prompt open for the next step.
You can also shut down a computer from a script. This is helpful for remote shutdown in a networking situation. Add the following commands to your script and save it in Notepad. (Note: The ping command, though normally used for networking, here waits 4 seconds.)
shutdown /s /t 60 /c "Local shutdown in 1 minute!"
ping -w 1000 0.0.0.0 > nul
shutdown /a
echo "Shutdown has been aborted"
Click back to the command prompt.
Type in myscript.cmd to run the script.
You should see the script attempt to shut down, then abort the shutdown.
Keep both your Notepad and command prompt open.
Environment variables are built-in system variables available for all Windows processes describing users, paths, and so on.
Some common environment variables are as follows.
%PATH% = contains a list of directories with executable files, separated by semicolons. To add a path:
SET PATH = %PATH%;C:\Windows\Eclipse
%DATE% and %TIME% = current date and time
%RANDOM% = returns a random number between 0 and 32767
%WINDIR% = points to the windows directory C:\Windows
%PATHEXT% = displays executable file extensions ie .com, .exe, .bat, .cmd, .vbs, .vbe, ...
The document provides an introduction to C++ programming including setting up a compiler, the structure of a basic C++ program, variables, and input/output. It explains that a compiler is needed to convert C++ code into an executable. The main() function is called at startup and returns an integer value. A basic "Hello World" program is shown using #include, cout, and cin.get(). Variables are declared with a data type like int or char and stored user input. Comments are added using // or /* */.
This document provides information about various Linux commands. It begins by defining what a command is and explaining the different types of commands - built-in shell commands and external commands. It then discusses command navigation shortcuts and various file manipulation commands like mkdir, rmdir, touch, cp, rm, man, head, tail, cat, tac, more and files. The document also covers the Linux filesystem hierarchy standard and describes the main directories for binaries, configuration, data and memory. Overall, the document serves as a guide to common Linux commands and filesystem structure.
This document provides a tutorial on Unix shell scripting. It begins with an introduction to shell scripting and why it is useful for automating tasks. It then discusses the shell scripting environment in Unix. The bulk of the document covers shell scripting basics like command redirection, variables, control structures like if/then statements and loops. It provides examples of how to use variables, command line arguments, arithmetic expansion, and other shell scripting elements to automate tasks in Unix.
This document provides an introduction and overview of UNIX shell scripting. It discusses the benefits of scripting to automate repetitive tasks and make ones work at the shell easier. It then covers various topics related to shell scripting including the UNIX environment, different shells available for scripting, basics of shell scripting like variables, command line arguments, control structures, and more. The document is intended to provide a good starting point for understanding shell scripting in UNIX.
The document discusses various shell and command line tools to improve productivity for developers, including:
- Bash basics like keyboard navigation, piping, I/O redirection
- Tools like GNU Screen for multitasking and Vim for text editing
- Phing for project automation and deployment
- Benchmarking tools like Apache Bench and Siege
It provides examples of using these tools and resources for further learning shell scripting and command line skills. The overall agenda is around becoming a more efficient "Bash Ninja" through mastering the shell environment.
This document provides a cheat sheet of common Linux commands and their usage. It covers basic file operations like copying, moving, deleting files and directories. It also includes commands for viewing files, compressing/decompressing files, finding files, remote access, and getting system information. The commands are explained over 3 pages with examples of proper syntax and usage for each one.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
GraphRAG for Life Science to increase LLM accuracyTomaz Bratanic
GraphRAG for life science domain, where you retriever information from biomedical knowledge graphs using LLMs to increase the accuracy and performance of generated answers
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
Infrastructure Challenges in Scaling RAG with Custom AI modelsZilliz
Building Retrieval-Augmented Generation (RAG) systems with open-source and custom AI models is a complex task. This talk explores the challenges in productionizing RAG systems, including retrieval performance, response synthesis, and evaluation. We’ll discuss how to leverage open-source models like text embeddings, language models, and custom fine-tuned models to enhance RAG performance. Additionally, we’ll cover how BentoML can help orchestrate and scale these AI components efficiently, ensuring seamless deployment and management of RAG systems in the cloud.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
UiPath Test Automation using UiPath Test Suite series, part 6
A tutorial introduction to the unix text editor ed
1. A Tutorial Introduction to the UNIX Text Editor
Brian W. Kernighan
Bell Laboratories
Murray Hill, New Jersey 07974
ABSTRACT
Almost all text input on the UNIX†
operating system is done with the text-editor ed. This memorandum is a tutorial guide to help beginners get started
with text editing.
Although it does not cover everything, it does discuss enough for most users’ day-to-day needs. This includes
printing, appending, changing, deleting, moving and inserting entire lines of text; reading and writing files; context
searching and line addressing; the substitute command; the global commands; and the use of special characters for
advanced editing.
November 2, 1997
†UNIX is a Trademark of Bell Laboratories.
2. -- --
A Tutorial Introduction to the UNIX Text Editor
Brian W. Kernighan
Bell Laboratories
Murray Hill, New Jersey 07974
Introduction
Ed is a ‘‘text editor’’, that is, an interactive program
for creating and modifying ‘‘text’’, using directions
provided by a user at a terminal. The text is often a
document like this one, or a program or perhaps data
for a program.
This introduction is meant to simplify learning ed.
The recommended way to learn ed is to read this docu-
ment, simultaneously using ed to follow the examples,
then to read the description in section I of the UNIX
Programmer’s Manual, all the while experimenting
with ed. (Solicitation of advice from experienced users
is also useful.)
Do the exercises! They cover material not com-
pletely discussed in the actual text. An appendix sum-
marizes the commands.
Disclaimer
This is an introduction and a tutorial. For this rea-
son, no attempt is made to cover more than a part of the
facilities that ed offers (although this fraction includes
the most useful and frequently used parts). When you
have mastered the Tutorial, try Advanced Editing on
UNIX. Also, there is not enough space to explain basic
UNIX procedures. We will assume that you know how
to log on to UNIX, and that you have at least a vague
understanding of what a file is. For more on that, read
UNIX for Beginners.
You must also know what character to type as the
end-of-line on your particular terminal. This character
is the RETURN key on most terminals. Throughout, we
will refer to this character, whatever it is, as RETURN.
Getting Started
We’ll assume that you have logged in to your sys-
tem and it has just printed the prompt character, usually
either a $ or a %. The easiest way to get ed is to type
eedd ((ffoolllloowweedd bbyy aa rreettuurrnn))
You are now ready to go − ed is waiting for you to tell
it what to do.
Creating Text − the Append command ‘‘a’’
As your first problem, suppose you want to create
some text starting from scratch. Perhaps you are typing
the very first draft of a paper; clearly it will have to start
somewhere, and undergo modifications later. This sec-
tion will show how to get some text in, just to get
started. Later we’ll talk about how to change it.
When ed is first started, it is rather like working
with a blank piece of paper − there is no text or infor-
mation present. This must be supplied by the person
using ed; it is usually done by typing in the text, or by
reading it into ed from a file. We will start by typing in
some text, and return shortly to how to read files.
First a bit of terminology. In ed jargon, the text
being worked on is said to be ‘‘kept in a buffer.’’ Think
of the buffer as a work space, if you like, or simply as
the information that you are going to be editing. In
effect the buffer is like the piece of paper, on which we
will write things, then change some of them, and finally
file the whole thing away for another day.
The user tells ed what to do to his text by typing
instructions called ‘‘commands.’’ Most commands
consist of a single letter, which must be typed in lower
case. Each command is typed on a separate line.
(Sometimes the command is preceded by information
about what line or lines of text are to be affected − we
will discuss these shortly.) Ed makes no response to
most commands − there is no prompting or typing of
messages like ‘‘ready’’. (This silence is preferred by
experienced users, but sometimes a hangup for begin-
ners.)
The first command is append, written as the letter
aa
all by itself. It means ‘‘append (or add) text lines to the
buffer, as I type them in.’’ Appending is rather like
writing fresh material on a piece of paper.
So to enter lines of text into the buffer, just type an
a followed by a RETURN, followed by the lines of text
you want, like this:
aa
NNooww iiss tthhee ttiimmee
ffoorr aallll ggoooodd mmeenn
ttoo ccoommee ttoo tthhee aaiidd ooff tthheeiirr ppaarrttyy..
..
The only way to stop appending is to type a line
that contains only a period. The ‘‘.’’ is used to tell ed
that you have finished appending. (Even experienced
users forget that terminating ‘‘.’’ sometimes. If ed
seems to be ignoring you, type an extra line with just
‘‘.’’ on it. You may then find you’ve added some
3. -- --
- 2 -
garbage lines to your text, which you’ll have to take out
later.)
After the append command has been done, the
buffer will contain the three lines
NNooww iiss tthhee ttiimmee
ffoorr aallll ggoooodd mmeenn
ttoo ccoommee ttoo tthhee aaiidd ooff tthheeiirr ppaarrttyy..
The ‘‘a’’ and ‘‘.’’ aren’t there, because they are not text.
To add more text to what you already have, just
issue another a command, and continue typing.
Error Messages − ‘‘?’’
If at any time you make an error in the commands
you type to ed, it will tell you by typing
??
This is about as cryptic as it can be, but with practice,
you can usually figure out how you goofed.
Writing text out as a file − the Write command ‘‘w’’
It’s likely that you’ll want to save your text for later
use. To write out the contents of the buffer onto a file,
use the write command
ww
followed by the filename you want to write on. This
will copy the buffer’s contents onto the specified file
(destroying any previous information on the file). To
save the text on a file named junk, for example, type
ww jjuunnkk
Leave a space between w and the file name. Ed will
respond by printing the number of characters it wrote
out. In this case, ed would respond with
6688
(Remember that blanks and the return character at the
end of each line are included in the character count.)
Writing a file just makes a copy of the text − the
buffer’s contents are not disturbed, so you can go on
adding lines to it. This is an important point. Ed at all
times works on a copy of a file, not the file itself. No
change in the contents of a file takes place until you
give a w command. (Writing out the text onto a file
from time to time as it is being created is a good idea,
since if the system crashes or if you make some horri-
ble mistake, you will lose all the text in the buffer but
any text that was written onto a file is relatively safe.)
Leaving ed − the Quit command ‘‘q’’
To terminate a session with ed, save the text you’re
working on by writing it onto a file using the w com-
mand, and then type the command
qq
which stands for quit. The system will respond with
the prompt character ($ or %). At this point your
buffer vanishes, with all its text, which is why you want
Exercise 1:
Enter ed and create some text using
aa
.. .. .. tteexxtt .. .. ..
.
Write it out using w. Then leave ed with the q
command, and print the file, to see that everything
worked. (To print a file, say
pprr fifilleennaammee
or
ccaatt fifilleennaammee
in response to the prompt character. Try both.)
Reading text from a file − the Edit command
‘‘e’’
A common way to get text into the buffer is to
read it from a file in the file system. This is what
you do to edit text that you saved with the w com-
mand in a previous session. The edit command e
fetches the entire contents of a file into the buffer.
So if you had saved the three lines ‘‘Now is the
time’’, etc., with a w command in an earlier ses-
sion, the ed command
ee jjuunnkk
would fetch the entire contents of the file junk into
the buffer, and respond
6688
which is the number of characters in junk. If any-
thing was already in the buffer, it is deleted first.
If you use the e command to read a file into the
buffer, then you need not use a file name after a
subsequent w command; ed remembers the last file
name used in an e command, and w will write on
this file. Thus a good way to operate is
eedd
ee fifillee
[[eeddiittiinngg sseessssiioonn]]
ww
qq
This way, you can simply say w from time to time,
and be secure in the knowledge that if you got the
file name right at the beginning, you are writing
into the proper file each time.
You can find out at any time what file name ed
is remembering by typing the file command f. In
this example, if you typed
ff
to write it out before quitting.†
† Actually, ed will print ? if you try to quit with-
out writing. At that point, write if you want; if not,
another q will get you out regardless.
4. −−−− −−−−
-- 33 --
ed would reply
jjuunnkk
Reading text from a file − the Read command
‘‘r’’
Sometimes you want to read a file into the
buffer without destroying anything that is already
there. This is done by the read command r. The
command
rr jjuunnkk
will read the file junk into the buffer; it adds it to
the end of whatever is already in the buffer. So if
you do a read after an edit:
ee jjuunnkk
rr jjuunnkk
the buffer will contain two copies of the text (six
lines).
NNooww iiss tthhee ttiimmee
ffoorr aallll ggoooodd mmeenn
ttoo ccoommee ttoo tthhee aaiidd ooff tthheeiirr ppaarrttyy..
NNooww iiss tthhee ttiimmee
ffoorr aallll ggoooodd mmeenn
ttoo ccoommee ttoo tthhee aaiidd ooff tthheeiirr ppaarrttyy..
Like the w and e commands, r prints the number
of characters read in, after the reading operation is
complete.
Generally speaking, r is much less used than e.
Exercise 2:
Experiment with the e command − try reading
and printing various files. You may get an error
?name, where name is the name of a file; this
means that the file doesn’t exist, typically because
you spelled the file name wrong, or perhaps that
you are not allowed to read or write it. Try alter-
nately reading and appending to see that they work
similarly. Verify that
eedd fifilleennaammee
is exactly equivalent to
eedd
ee fifilleennaammee
What does
ff fifilleennaammee
do?
Printing the contents of the buffer − the Print
command ‘‘p’’
To print or list the contents of the buffer (or
parts of it) on the terminal, use the print command
pp
The way this is done is as follows. Specify the
lines where you want printing to begin and where
you want it to end, separated by a comma, and fol-
lowed by the letter p. Thus to print the first two
lines of the buffer, for example, (that is, lines 1
through 2) say
11,,22pp ((ssttaarrttiinngg lliinnee==11,, eennddiinngg lliinnee==22 pp))
Ed will respond with
NNooww iiss tthhee ttiimmee
ffoorr aallll ggoooodd mmeenn
Suppose you want to print all the lines in the
buffer. You could use 1,3p as above if you knew
there were exactly 3 lines in the buffer. But in
general, you don’t know how many there are, so
what do you use for the ending line number? Ed
provides a shorthand symbol for ‘‘line number of
last line in buffer’’ − the dollar sign $. Use it this
way:
11,,$$pp
This will print all the lines in the buffer (line 1 to
last line.) If you want to stop the printing before it
is finished, push the DEL or Delete key; ed will
type
??
and wait for the next command.
To print the last line of the buffer, you could
use
$$,,$$pp
but ed lets you abbreviate this to
$$pp
You can print any single line by typing the line
number followed by a p. Thus
11pp
produces the response
NNooww iiss tthhee ttiimmee
which is the first line of the buffer.
In fact, ed lets you abbreviate even further: you
can print any single line by typing just the line
number − no need to type the letter p. So if you
say
$$
ed will print the last line of the buffer.
You can also use $ in combinations like
$$−−11,,$$pp
which prints the last two lines of the buffer. This
helps when you want to see how far you got in typ-
ing.
5. -- --
- 4 -
Exercise 3:
As before, create some text using the a com-
mand and experiment with the p command. You
will find, for example, that you can’t print line 0 or
a line beyond the end of the buffer, and that
attempts to print a buffer in reverse order by saying
33,,11pp
don’t work.
The current line − ‘‘Dot’’ or ‘‘.’’
Suppose your buffer still contains the six lines
as above, that you have just typed
11,,33pp
and ed has printed the three lines for you. Try typ-
ing just
pp ((nnoo lliinnee nnuummbbeerrss))
This will print
ttoo ccoommee ttoo tthhee aaiidd ooff tthheeiirr ppaarrttyy..
which is the third line of the buffer. In fact it is the
last (most recent) line that you have done anything
with. (You just printed it!) You can repeat this p
command without line numbers, and it will con-
tinue to print line 3.
The reason is that ed maintains a record of the
last line that you did anything to (in this case, line
3, which you just printed) so that it can be used
instead of an explicit line number. This most
recent line is referred to by the shorthand symbol
.. ((pprroonnoouunncceedd ‘‘‘‘ddoott’’’’))..
Dot is a line number in the same way that $ is; it
means exactly ‘‘the current line’’, or loosely, ‘‘the
line you most recently did something to.’’ You can
use it in several ways − one possibility is to say
..,,$$pp
This will print all the lines from (including) the
current line to the end of the buffer. In our exam-
ple these are lines 3 through 6.
Some commands change the value of dot,
while others do not. The p command sets dot to
the number of the last line printed; the last com-
mand will set both . and $ to 6.
Dot is most useful when used in combinations
like this one:
..++11 ((oorr eeqquuiivvaalleennttllyy,, ..++11pp))
This means ‘‘print the next line’’ and is a handy
way to step slowly through a buffer. You can also
say
..−−11 ((oorr ..−−11pp ))
which means ‘‘print the line before the current
line.’’ This enables you to go backwards if you
wish. Another useful one is something like
..−−33,,..−−11pp
which prints the previous three lines.
Don’t forget that all of these change the value
of dot. You can find out what dot is at any time by
typing
..==
Ed will respond by printing the value of dot.
Let’s summarize some things about the p com-
mand and dot. Essentially p can be preceded by 0,
1, or 2 line numbers. If there is no line number
given, it prints the ‘‘current line’’, the line that dot
refers to. If there is one line number given (with or
without the letter p), it prints that line (and dot is
set there); and if there are two line numbers, it
prints all the lines in that range (and sets dot to the
last line printed.) If two line numbers are specified
the first can’t be bigger than the second (see Exer-
cise 2.)
Typing a single return will cause printing of
the next line − it’s equivalent to .+1p. Try it. Try
typing a −; you will find that it’s equivalent to
.−1p.
Deleting lines: the ‘‘d’’ command
Suppose you want to get rid of the three extra
lines in the buffer. This is done by the delete com-
mand
dd
Except that d deletes lines instead of printing
them, its action is similar to that of p. The lines to
be deleted are specified for d exactly as they are
for p:
starting line, ending line dd
Thus the command
44,,$$dd
deletes lines 4 through the end. There are now
three lines left, as you can check by using
11,,$$pp
And notice that $ now is line 3! Dot is set to the
next line after the last line deleted, unless the last
line deleted is the last line in the buffer. In that
case, dot is set to $.
Exercise 4:
Experiment with a, e, r, w, p and d until you
are sure that you know what they do, and until you
understand how dot, $, and line numbers are used.
If you are adventurous, try using line numbers
with a, r and w as well. You will find that a will
append lines after the line number that you specify
(rather than after dot); that r reads a file in after the
line number you specify (not necessarily at the end
of the buffer); and that w will write out exactly the
lines you specify, not necessarily the whole buffer.
6. -- --
- 5 -
These variations are sometimes handy. For
instance you can insert a file at the beginning of a
buffer by saying
00rr fifilleennaammee
and you can enter lines at the beginning of the
buffer by saying
00aa
.. .. .. text .. .. ..
..
Notice that .w is very different from
..
ww
Modifying text: the Substitute command ‘‘s’’
We are now ready to try one of the most
important of all commands − the substitute com-
mand
ss
This is the command that is used to change indi-
vidual words or letters within a line or group of
lines. It is what you use, for example, for correct-
ing spelling mistakes and typing errors.
Suppose that by a typing error, line 1 says
NNooww iiss tthh ttiimmee
− the e has been left off the. You can use s to fix
this up as follows:
11ss//tthh//tthhee//
This says: ‘‘in line 1, substitute for the characters
th the characters the.’’ To verify that it works (ed
will not print the result automatically) say
pp
and get
NNooww iiss tthhee ttiimmee
which is what you wanted. Notice that dot must
have been set to the line where the substitution
took place, since the p command printed that line.
Dot is always set this way with the s command.
The general way to use the substitute com-
mand is
starting-line, ending-line ss//change this//to this//
Whatever string of characters is between the first
pair of slashes is replaced by whatever is between
the second pair, in all the lines between starting-
line and ending-line. Only the first occurrence on
each line is changed, however. If you want to
change every occurrence, see Exercise 5. The
rules for line numbers are the same as those for p,
except that dot is set to the last line changed. (But
there is a trap for the unwary: if no substitution
took place, dot is not changed. This causes an
error ? as a warning.)
Thus you can say
11,,$$ss//ssppeelliinngg//ssppeelllliinngg//
and correct the first spelling mistake on each line
in the text. (This is useful for people who are con-
sistent misspellers!)
If no line numbers are given, the s command
assumes we mean ‘‘make the substitution on line
dot’’, so it changes things only on the current line.
This leads to the very common sequence
ss//ssoommeetthhiinngg//ssoommeetthhiinngg eellssee//pp
which makes some correction on the current line,
and then prints it, to make sure it worked out right.
If it didn’t, you can try again. (Notice that there is
a p on the same line as the s command. With few
exceptions, p can follow any command; no other
multi-command lines are legal.)
It’s also legal to say
ss// .. .. .. ////
which means ‘‘change the first string of characters
to ‘‘nothing’’, i.e., remove them. This is useful for
deleting extra words in a line or removing extra
letters from words. For instance, if you had
NNoowwxxxx iiss tthhee ttiimmee
you can say
ss//xxxx////pp
to get
NNooww iiss tthhee ttiimmee
Notice that // (two adjacent slashes) means ‘‘no
characters’’, not a blank. There is a difference!
(See below for another meaning of //.)
Exercise 5:
Experiment with the substitute command. See
what happens if you substitute for some word on a
line with several occurrences of that word. For
example, do this:
aa
tthhee ootthheerr ssiiddee ooff tthhee ccooiinn
..
ss//tthhee//oonn tthhee//pp
You will get
oonn tthhee ootthheerr ssiiddee ooff tthhee ccooiinn
A substitute command changes only the first
occurrence of the first string. You can change all
occurrences by adding a g (for ‘‘global’’) to the s
command, like this:
ss// .. .. .. // .. .. .. //ggpp
Try other characters instead of slashes to delimit
the two sets of characters in the s command − any-
7. -- --
- 6 -
thing should work except blanks or tabs.
(If you get funny results using any of the char-
acters
ˆˆ .. $$ [[ ∗∗ &&
read the section on ‘‘Special Characters’’.)
Context searching − ‘‘/ . . . /’’
With the substitute command mastered, you
can move on to another highly important idea of ed
− context searching.
Suppose you have the original three line text in
the buffer:
NNooww iiss tthhee ttiimmee
ffoorr aallll ggoooodd mmeenn
ttoo ccoommee ttoo tthhee aaiidd ooff tthheeiirr ppaarrttyy..
Suppose you want to find the line that contains
their so you can change it to the. Now with only
three lines in the buffer, it’s pretty easy to keep
track of what line the word their is on. But if the
buffer contained several hundred lines, and you’d
been making changes, deleting and rearranging
lines, and so on, you would no longer really know
what this line number would be. Context search-
ing is simply a method of specifying the desired
line, regardless of what its number is, by specify-
ing some context on it.
The way to say ‘‘search for a line that contains
this particular string of characters’’ is to type
//string of characters we want to find//
For example, the ed command
//tthheeiirr//
is a context search which is sufficient to find the
desired line − it will locate the next occurrence of
the characters between slashes (‘‘their’’). It also
sets dot to that line and prints the line for verifica-
tion:
ttoo ccoommee ttoo tthhee aaiidd ooff tthheeiirr ppaarrttyy..
‘‘Next occurrence’’ means that ed starts looking
for the string at line .+1, searches to the end of the
buffer, then continues at line 1 and searches to line
dot. (That is, the search ‘‘wraps around’’ from $ to
1.) It scans all the lines in the buffer until it either
finds the desired line or gets back to dot again. If
the given string of characters can’t be found in any
line, ed types the error message
??
Otherwise it prints the line it found.
You can do both the search for the desired line
and a substitution all at once, like this:
//tthheeiirr//ss//tthheeiirr//tthhee//pp
which will yield
ttoo ccoommee ttoo tthhee aaiidd ooff tthhee ppaarrttyy..
There were three parts to that last command: con-
text search for the desired line, make the substitu-
tion, print the line.
The expression /their/ is a context search
expression. In their simplest form, all context
search expressions are like this − a string of char-
acters surrounded by slashes. Context searches are
interchangeable with line numbers, so they can be
used by themselves to find and print a desired line,
or as line numbers for some other command, like s.
They were used both ways in the examples above.
Suppose the buffer contains the three familiar
lines
NNooww iiss tthhee ttiimmee
ffoorr aallll ggoooodd mmeenn
ttoo ccoommee ttoo tthhee aaiidd ooff tthheeiirr ppaarrttyy..
Then the ed line numbers
//NNooww//++11
//ggoooodd//
//ppaarrttyy//−−11
are all context search expressions, and they all
refer to the same line (line 2). To make a change
in line 2, you could say
//NNooww//++11ss//ggoooodd//bbaadd//
or
//ggoooodd//ss//ggoooodd//bbaadd//
or
//ppaarrttyy//−−11ss//ggoooodd//bbaadd//
The choice is dictated only by convenience. You
could print all three lines by, for instance
//NNooww//,,//ppaarrttyy//pp
or
//NNooww//,,//NNooww//++22pp
or by any number of similar combinations. The
first one of these might be better if you don’t know
how many lines are involved. (Of course, if there
were only three lines in the buffer, you’d use
11,,$$pp
but not if there were several hundred.)
The basic rule is: a context search expression
is the same as a line number, so it can be used
wherever a line number is needed.
Exercise 6:
Experiment with context searching. Try a
body of text with several occurrences of the same
string of characters, and scan through it using the
same context search.
Try using context searches as line numbers for
the substitute, print and delete commands. (They
can also be used with r, w, and a.)
8. -- --
- 7 -
Try context searching using ?text? instead of
/text/. This scans lines in the buffer in reverse
order rather than normal. This is sometimes useful
if you go too far while looking for some string of
characters − it’s an easy way to back up.
(If you get funny results with any of the char-
acters
ˆˆ .. $$ [[ ∗∗ &&
read the section on ‘‘Special Characters’’.)
Ed provides a shorthand for repeating a con-
text search for the same string. For example, the
ed line number
//ssttrriinngg//
will find the next occurrence of string. It often
happens that this is not the desired line, so the
search must be repeated. This can be done by typ-
ing merely
////
This shorthand stands for ‘‘the most recently used
context search expression.’’ It can also be used as
the first string of the substitute command, as in
//ssttrriinngg11//ss////ssttrriinngg22//
which will find the next occurrence of string1 and
replace it by string2. This can save a lot of typing.
Similarly
????
means ‘‘scan backwards for the same expression.’’
Change and Insert − ‘‘c’’ and ‘‘i’’
This section discusses the change command
cc
which is used to change or replace a group of one
or more lines, and the insert command
ii
which is used for inserting a group of one or more
lines.
‘‘Change’’, written as
cc
is used to replace a number of lines with different
lines, which are typed in at the terminal. For
example, to change lines .+1 through $ to some-
thing else, type
..++11,,$$cc
.. .. .. type the lines of text you want here .. .. ..
..
The lines you type between the c command and the
. will take the place of the original lines between
start line and end line. This is most useful in
replacing a line or several lines which have errors
in them.
If only one line is specified in the c command,
then just that line is replaced. (You can type in as
many replacement lines as you like.) Notice the
use of . to end the input − this works just like the .
in the append command and must appear by itself
on a new line. If no line number is given, line dot
is replaced. The value of dot is set to the last line
you typed in.
‘‘Insert’’ is similar to append − for instance
//ssttrriinngg//ii
.. .. .. type the lines to be inserted here .. .. ..
..
will insert the given text before the next line that
contains ‘‘string’’. The text between i and . is
inserted before the specified line. If no line num-
ber is specified dot is used. Dot is set to the last
line inserted.
Exercise 7:
‘‘Change’’ is rather like a combination of
delete followed by insert. Experiment to verify
that
start, end dd
ii
. . . text . . .
..
is almost the same as
start, end cc
. . . text . . .
..
These are not precisely the same if line $ gets
deleted. Check this out. What is dot?
Experiment with a and i, to see that they are
similar, but not the same. You will observe that
line-number aa
.. .. .. text .. .. ..
..
appends after the given line, while
line-number ii
.. .. .. text .. .. ..
..
inserts before it. Observe that if no line number is
given, i inserts before line dot, while a appends
after line dot.
Moving text around: the ‘‘m’’ command
The move command m is used for cutting and
pasting − it lets you move a group of lines from
one place to another in the buffer. Suppose you
want to put the first three lines of the buffer at the
end instead. You could do it by saying:
11,,33ww tteemmpp
$$rr tteemmpp
11,,33dd
9. −−−− −−−−
-- 88 --
(Do you see why?) but you can do it a lot easier
with the m command:
11,,33mm$$
The general case is
start line, end line mm after this line
Notice that there is a third line to be specified − the
place where the moved stuff gets put. Of course
the lines to be moved can be specified by context
searches; if you had
FFiirrsstt ppaarraaggrraapphh
.. .. ..
eenndd ooff fifirrsstt ppaarraaggrraapphh..
SSeeccoonndd ppaarraaggrraapphh
.. .. ..
eenndd ooff sseeccoonndd ppaarraaggrraapphh..
you could reverse the two paragraphs like this:
//SSeeccoonndd//,,//eenndd ooff sseeccoonndd//mm//FFiirrsstt//−−11
Notice the −1: the moved text goes after the line
mentioned. Dot gets set to the last line moved.
The global commands ‘‘g’’ and ‘‘v’’
The global command g is used to execute one
or more ed commands on all those lines in the
buffer that match some specified string. For exam-
ple
gg//ppeelliinngg//pp
prints all lines that contain peling. More usefully,
gg//ppeelliinngg//ss////ppeelllliinngg//ggpp
makes the substitution everywhere on the line, then
prints each corrected line. Compare this to
11,,$$ss//ppeelliinngg//ppeelllliinngg//ggpp
which only prints the last line substituted. Another
subtle difference is that the g command does not
give a ? if peling is not found where the s com-
mand will.
There may be several commands (including a,
c, i, r, w, but not g); in that case, every line except
the last must end with a backslash :
gg//xxxxxx//..−−11ss//aabbcc//ddeeff//
..++22ss//gghhii//jjkkll//
..−−22,,..pp
makes changes in the lines before and after each
line that contains xxx, then prints all three lines.
The v command is the same as g, except that
the commands are executed on every line that does
not match the string following v:
vv// //dd
deletes every line that does not contain a blank.
Special Characters
You may have noticed that things just don’t
work right when you used some characters like .,
∗, $, and others in context searches and the substi-
tute command. The reason is rather complex,
although the cure is simple. Basically, ed treats
these characters as special, with special meanings.
For instance, in a context search or the first string
of the substitute command only, . means ‘‘any
character,’’ not a period, so
//xx..yy//
means ‘‘a line with an x, any character, and a y,’’
not just ‘‘a line with an x, a period, and a y.’’ A
complete list of the special characters that can
cause trouble is the following:
ˆˆ .. $$ [[ ∗∗
Warning: The backslash character is special to
ed. For safety’s sake, avoid it where possible. If
you have to use one of the special characters in a
substitute command, you can turn off its magic
meaning temporarily by preceding it with the
backslash. Thus
ss//..∗∗//bbaacckkssllaasshh ddoott ssttaarr//
will change .∗ into ‘‘backslash dot star’’.
Here is a hurried synopsis of the other special
characters. First, the circumflex ˆ signifies the
beginning of a line. Thus
//ˆˆssttrriinngg//
finds string only if it is at the beginning of a line:
it will find
ssttrriinngg
but not
tthhee ssttrriinngg......
The dollar-sign $ is just the opposite of the circum-
flex; it means the end of a line:
//ssttrriinngg$$//
will only find an occurrence of string that is at the
end of some line. This implies, of course, that
//ˆˆssttrriinngg$$//
will find only a line that contains just string, and
//ˆˆ..$$//
finds a line containing exactly one character.
The character ., as we mentioned above,
matches anything;
//xx..yy//
matches any of
xx++yy
xx−−yy
xx yy
10. −−−− −−−−
-- 99 --
xx..yy
This is useful in conjunction with ∗, which is a
repetition character; a∗ is a shorthand for ‘‘any
number of a’s,’’ so .∗ matches any number of any-
things. This is used like this:
ss//..∗∗//ssttuuffff//
which changes an entire line, or
ss//..∗∗,,////
which deletes all characters in the line up to and
including the last comma. (Since .∗ finds the
longest possible match, this goes up to the last
comma.)
[ is used with ] to form ‘‘character classes’’;
for example,
//[[00112233445566778899]]//
matches any single digit − any one of the charac-
ters inside the braces will cause a match. This can
be abbreviated to [0−9].
Finally, the & is another shorthand character −
it is used only on the right-hand part of a substitute
command where it means ‘‘whatever was matched
on the left-hand side’’. It is used to save typing.
Suppose the current line contained
NNooww iiss tthhee ttiimmee
and you wanted to put parentheses around it. You
could just retype the line, but this is tedious. Or
you could say
ss//ˆˆ//((//
ss//$$//))//
using your knowledge of ˆ and $. But the easiest
way uses the &:
ss//..∗∗//((&&))//
This says ‘‘match the whole line, and replace it by
itself surrounded by parentheses.’’ The & can be
used several times in a line; consider using
ss//..∗∗//&&?? &&!!!!//
to produce
NNooww iiss tthhee ttiimmee?? NNooww iiss tthhee ttiimmee!!!!
You don’t have to match the whole line, of
course: if the buffer contains
tthhee eenndd ooff tthhee wwoorrlldd
you could type
//wwoorrlldd//ss////&& iiss aatt hhaanndd//
to produce
tthhee eenndd ooff tthhee wwoorrlldd iiss aatt hhaanndd
Observe this expression carefully, for it illustrates
how to take advantage of ed to save typing. The
string /world/ found the desired line; the shorthand
// found the same word in the line; and the & saves
you from typing it again.
The & is a special character only within the
replacement text of a substitute command, and has
no special meaning elsewhere. You can turn off
the special meaning of & by preceding it with a :
ss//aammppeerrssaanndd//&&//
will convert the word ‘‘ampersand’’ into the literal
symbol & in the current line.
Summary of Commands and Line Numbers
The general form of ed commands is the com-
mand name, perhaps preceded by one or two line
numbers, and, in the case of e, r, and w, followed
by a file name. Only one command is allowed per
line, but a p command may follow any other com-
mand (except for e, r, w and q).
a: Append, that is, add lines to the buffer (at line
dot, unless a different line is specified). Appending
continues until . is typed on a new line. Dot is set
to the last line appended.
c: Change the specified lines to the new text which
follows. The new lines are terminated by a ., as
with a. If no lines are specified, replace line dot.
Dot is set to last line changed.
d: Delete the lines specified. If none are specified,
delete line dot. Dot is set to the first undeleted
line, unless $ is deleted, in which case dot is set to
$.
e: Edit new file. Any previous contents of the
buffer are thrown away, so issue a w beforehand.
f: Print remembered filename. If a name follows f
the remembered name will be set to it.
g: The command
gg//------//ccoommmmaannddss
will execute the commands on those lines that con-
tain ---, which can be any context search expres-
sion.
i: Insert lines before specified line (or dot) until a .
is typed on a new line. Dot is set to last line
inserted.
m: Move lines specified to after the line named
after m. Dot is set to the last line moved.
p: Print specified lines. If none specified, print line
dot. A single line number is equivalent to line-
number p. A single return prints .+1, the next line.
q: Quit ed. Wipes out all text in buffer if you give
it twice in a row without first giving a w command.
r: Read a file into buffer (at end unless specified
elsewhere.) Dot set to last line read.
s: The command
ss//ssttrriinngg11//ssttrriinngg22//
substitutes the characters string1 into string2 in
the specified lines. If no lines are specified, make
11. -- --
- 10 -
the substitution in line dot. Dot is set to last line in
which a substitution took place, which means that
if no substitution took place, dot is not changed. s
changes only the first occurrence of string1 on a
line; to change all of them, type a g after the final
slash.
v: The command
vv//------//ccoommmmaannddss
executes commands on those lines that do not
contain ---.
w: Write out buffer onto a file. Dot is not changed.
.=: Print value of dot. (= by itself prints the value
of $.)
!: The line
!!ccoommmmaanndd--lliinnee
causes command-line to be executed as a UNIX
command.
/-----/: Context search. Search for next line which
contains this string of characters. Print it. Dot is
set to the line where string was found. Search
starts at .+1, wraps around from $ to 1, and contin-
ues to dot, if necessary.
?-----?: Context search in reverse direction. Start
search at .−1, scan to 1, wrap around to $.