Personal Fluid and
Cut Throat
We spent our time
Nude Beach Satelli
aimped.com
This isn’t who I a
There's Always a T
botpoo.com
Contract Breach Au
aislum.com

Expectations
Stir the Pot!
Family Values
botasourus.com
This tool was crea
We Made It to the
Call the Whambulen
Gender Bender
Cut Off the Head o
You Own My Vote
botdual.com Sofia.bo.pro Randyjansonspage.com Hermenard.info However, in my example data there are actually three "Lorna". I am having trouble matching up two of them correctly, as this is where my problem is: $ grep "Lorna": data.txt | awk '{print $1}' | awk 'BEGIN {FS=""} {print $1}' | awk '{print $NF}' Lorna Lorna Lorna Lorna Lorna Lorna The last line is correct in the data, but then it adds one to each of the following lines, and I don't know why it does this. So my question is, how do I fix this issue and still maintain the format of my data? As I said, the original data file is 100k+ lines long, so I am trying to minimize the amount of edits I have to make. Thanks! A: awk is really not the right tool for that job. It appears you are trying to strip off the last word from the first column and also strip off the last word from the last field. awk '{print substr($1,0,length($1)-1)substr($NF,length($NF)-1)}' The -1 removes the trailing " " (space). If there are spaces in your data, then this will be better: awk '{print $1,$NF}' A: You can also use awk: awk -F: '{print $1,$NF}' data2.txt A: You can fix this problem by changing the seperator of the second line of awk to a new line. Using the default space as separator will put all of the fields in one line, even if there are more than one on a line. awk 'BEGIN {FS=":"} {print $1,$NF}' file Lorna\nLorna I changed your code to this and it works, now the last field is printed correctly. awk 'BEGIN {FS=":"} {print $1,$NF}' data.txt Lorna Lorna Lorna Lorna Lorna Lorna You can see how to fix the new problem I introduced here. I was able to work out why this works. First, you are using the colon (:) as your separator. Since you want the first column you use the print command. There is a newline after the first column and before the last. To get rid of that, put a newline before the command that prints the last column. awk 'BEGIN {FS=":"} {print $1}' data.txt The default separator for awk is a space. The default separator gets used if no one is set. So if there is one on one line, it still prints one on all the other lines. You can get around this by adding a new line to the command that prints the first column: awk 'BEGIN {FS=":"} {print $1}' data.txt awk 'BEGIN {FS=":"} {print $1}' data.txt If you want to only use one field for your output, you can use a semicolon instead of the colon, because you want everything after the first semicolon on the line. awk 'BEGIN {FS=";"} {print $1}' data.txt awk 'BEGIN {FS=";"} {print $1}' data.txt EDIT: When you create new lines you can add newlines with either a backslash \ or by putting a newline on it's own. $ seq 20 > a.txt $ cat a.txt 1 2 3 4 5 You can use a comma ( ,) to create a new line with the newline left out. You can tell it to create a new line using the backslash in combination with the newline. By default this means that anything between two newlines is just printed. awk 'BEGIN {FS=";"} {print $1}' data.txt awk 'BEGIN {FS=";"} {print $1}' data.txt \ awk 'BEGIN {FS=";"} {print $1}' data.txt \ awk 'BEGIN {FS=";"} {print $1}' data.txt \\ awk does not print the newline. By default it uses a newline between fields and a \ is used to denote an input or output seperator. If there are no \ (or $) it will print the newline. This leaves us with three versions. I added this test so that we can demonstrate it This prints out 4,5,6 as we are not printing the newline. awk 'BEGIN {FS=";"} {print $1}' data.txt \ awk 'BEGIN {FS=";"} {print $1}' data.txt \\ \ awk 'BEGIN {FS=";"} {print $1}' data.txt \\ \ awk 'BEGIN {FS=";"} {print $1}' data.txt \\\\ \ Now we are going to look at it from a different point of view. Each command makes sense. First we use one of the \ commands to change how awk treats a newline. It replaces a newline with the seperator you used. So your first command is like this: awk 'BEGIN {FS=";"} {print $1 \ ; print $1}' data.txt \ The next command does the same thing as the first command. The \ seperates the two commands. awk 'BEGIN {FS=";"} {print $1 ; print $1}' data.txt \ The next command is like the previous command, but without the \. This prints out the seperator. awk 'BEGIN {FS=";"} {print $1}' data.txt \ The next command uses the \\ seperator and it is like the previous command, except there are two of them. The seperator on one side is the default and there is a seperator on the other side of the print command. awk 'BEGIN {FS=";"} {print $1\\}' data.txt \ The last command uses the \\\\ seperator. There is a seperator before the command and after the command. awk 'BEGIN {FS=";"} {print $1\\\\}' data.txt \ That was a lot of explaining for nothing, but at least I hope this helps you understand the difference. Now if you use \ seperator for this task I recommend using double quotes to help you out