Jump to content
Due to a large amount of spamers, accounts will now have to be approved by the Admins so please be patient. ×
IGNORED

Mac App to delete lines in a text document?


Recommended Posts

Hi all,

 

I am currently editing a large text document on my Mac and there is a lot of repeated lines that I would like to remove. Is there an app/program for the Mac that can search a text file using regular expressions and delete the entire lines that match, including the carriage returns?

 

Cheers,

Matthew

Link to comment
Share on other sites

type 'man uniq' in terminal. vi or your preferred editor might help too. resort to perl if you must.. these are tool not solutions i realise but thats what you use to do it.

 

note uniq wont match two lines that arent consecutive

 

eg

 

dog

cat

dog

fish

fish

 

will only see the extra fish.. not the dog

Link to comment
Share on other sites

Hi all,

 

I am currently editing a large text document on my Mac and there is a lot of repeated lines that I would like to remove. Is there an app/program for the Mac that can search a text file using regular expressions and delete the entire lines that match, including the carriage returns?

 

Cheers,

Matthew

 

grep -v

will output every line from a file that doesn't have a match for a specific pattern.

Link to comment
Share on other sites

type 'man uniq' in terminal. vi or your preferred editor might help too. resort to perl if you must.. these are tool not solutions i realise but thats what you use to do it.

 

note uniq wont match two lines that arent consecutive

 

eg

 

dog

cat

dog

fish

fish

 

will only see the extra fish.. not the dog

 

If you pipe to sort first, then uniq you'll be golden but you'll loose the original order.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...