will be helpful for those in need This sounds simple on its face but is actually somewhat more complex. I would like to use a unix utility to delete consecutive duplicates, leaving the original. But, I would also like to preserve other duplicates that do not occur immediately after the original. For example, if we have the lines: , You can do:
cat file1 | uniq > file2
uniq file1 file2
sort -u file1 > file2
How do I delete lines matching multiple pattern in text file using bash command?
will be helpful for those in need I have a text file and want to delete lines that start with A, T, G or C. If it's only A, I could have done like this sed '/A/d' infile.txt, but how do you delete lines that start with A,T,G or C letters? , You could use sed:
sed '/^[ATGC]/d' infile.txt
grep -v '^[ATGC]'
while read -r line; do [[ $line =~ ^[ATGC] ]] || echo "$line"; done < infile.txt