sed sed s/this/that/ input_file.txt > output_file.txt Read the file input_file.txt On every line replace the string "this" with the string "that". Write the result to the file output_file.txt sed -e /string_1/d -e /string_2/d input_file.txt > output_file.txt Read the file input_file.txt Deletes every line that contains sting_1. Make another pass and deletes every line that contains string_2. Writes the result to the file output_file.txt In the command line put "" around the string if it contains special characters, e.g. spaces. From trying things, it appears to me that Input_file and output_file must be different filenames. sed -n \ -e /'string_1 '/p \ -e /'string_2 '/p \ input_comps_file.txt > output_file.txt Read each line of the input file. Write that line into the output file only if it includes either string_1 or string_2. sed 's_# MIGT>_// MIGT>_' output_file Look for the string "# MIGT>" and substitute for it the string "// MIGT>". The whole thing has been put in single quotes i.e. ' because I may have some meta-characters in this command line. I have used the underbar character as the delimiter character in this command line (instead of the default / character) because I need the / character as part of the string that will be substituded in. Note that the strings do include a blank character. sed 's/[^^]#.*//' temp_in_junk.txt > temp_out_junk.txt s is the sed substitute command. This uses the default / character as the delimiter. [^^] here [^bla] means anything except bla and the 2nd ^ refers to the beginning of a line. So [^^] matches anything except for the beginning of a line. # is the just saying that the matching string must have the # character in it. .* is any character any number of times // the first / is the delimiter to indicate the end of the string you are searching for the second / indicates the end of the string that you are going to use to replace the searched string when you find it. The whole thing has been put in single quotes i.e. ' because it may have some meta-characters in this command line. sed '$a\ Add this line at the end of the file' \ gth_fanout_comps_4.txt > new_gth_fanout_comps_4.txt This is using sed to insert a full line of text at the end of a file. The "$" gets you to the end of the file and the "a" is the add command. For adding at a given line number I think that you just use a number (e.g. 124) instead of the "$". Must have no spaces or junk after the initial "\". The second "\" is just the continuation on the 3rd line with the filenames. For sed, leading off with a $ must have the special meaning of - end of file. sed 's/[ ]*$//' input_file.txt > output_file.txt Remove trailing space characters from the end of every line in a file. s for the normal sed substitute command. / for the normal sed delimiter. [ ] for the space character. * for repeat as many times as you want. $ for the regular expression end of line "anchor" // delimiters showing that nothing is to be substituted for the white space that is being pulled out at the end of every line in the file. ' all in single quotes so that the shell passes the full command to the sed program without interpreting the meta-characters. sed 's/^/add_this /' input_file.txt > output_file.txt Add some text at the beginning of each line in a file. s for the normal sed substitute command. / for the normal sed delimiter. ^ the regular expression begin of line anchor /text / the text that you want added at the beginning of each line. sed -e '/^\/\// d' temp_work_1.txt > temp_work_2.txt The goal is to delete all lines that start with // from the input file. The delimiter character is still the normal / ^ matches the beginning of a line \/ is an escaped / that is it is the real character / and does not have its special meaning of delimiting the pattern. Note also that it is legal to have a space between the end of the pattern and the d for delete command. This makes it easier to read. Things are in single quotes ' just to make sure that they all get passed to the sed program intact. The single quotes include both the pattern and the command. NOTE if you are using a take file for the script then you do not want to include them in single quotes '. This is because they are going directly to the sed program and are not passing through the shell where the single quotes protects them. Get straight the ideas of: - a delimited character string that is a pattern that must be matched befor a command will actually take any action - a delimited character string this is an argument to a command, e.g. the substitute command. sed 's/^/\/"/' working_pin_list.txt > temp_work.txt Goal: At the beginning of every line in the file add tje string /" s is the substitute command / is the delimiter ^ matches the beginning of a line. \/ is the escaped / so that just a normal / may be added to each line. Everything is in single quotes. sed 's/^.*/&,\/ d/' temp_work.txt > full_pin_remove_1.txt Goal: At to the end of every line at the string ,/ d s is the substitute command / is the delimiter. \/ is the escaped / so that just a normal / may be part of the text that is added to the end of each line. ^ matches the beginning of a line. .* matches any number of any other characters. & is special - it represents the pattern that was matched. sed -n /'pattern_1'/,/'Pattern 2'/p \ \ input_file.txt > output_file.txt Goal: copy from the input file to the output file all of the lines from the first one matching 'pattern_1 through the line matching 'Pattern 2'. sed 's/^.*U1-//' input_file.txt > output_file.txt Goal: From every line in the file remove everything from the beginning of the line through the U1- characters and then print out whatever is left. ^ regexp match the beginning of line $ regexp match the end of line . regexp match any single character * regexp matches zero or more occurrences of the previous character [chars] regexp matches any one of the characters in chars, where chars is a sequence of characters. Can use - to indicate a range of characters. set set prompt = "next>" set term = vt100 set followed by no arguments will display the values of all shell variables