Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Deleting lines in .txt with nonspecific value Post 302445345 by ygemici on Sunday 15th of August 2010 12:20:07 PM
Old 08-15-2010
you can a write script for more safely but i can also try a something Smilie

"more than 3 numbers"
Code:
 
# sed '/[0-9]\{4,\}\|[0-9]\{1\}.*[0-9]\{1\}.*[0-9]\{1\}.*[0-9]\{1\}/d' infile

"less than 4 characters"
Code:
# sed '/.*[A-Za-z]\{4,\}\|[A-Za-z]\{1,\}[^A-Za-z]\{1,\}[A-Za-z]\{1,\}[A-Za-z]\{1,\}[^A-Za-z]\{1,\}\|[A-Z]\{1\}[^A-Za-z]\{1\}[A-Z]\{3,\}|\[A-Z]\{2\}[^A-Za-z]\{1,\}[A-Z]{2,\}\|[A-Z]\{3\}[^A-Za-z]\{1,\}.*\|[A-Z]\{1,\}[^A-Za-z]\{1,\}[A-Z]\{1,\}[^A-Za-z]\{1,\}[A-Z]\{1,\}[^A-Za-z]\{1,\}[A-Z]\{1,\}\|[A-Za-z]\{3\}[^A-Za-z]\{1,\}[A-Za-z]\{1,\}\|[A-Z]\{1,\} [A-Z]\{1,\} [A-Z]\{1,\}\|[A-Z]\{1,\} [^A-Z]\{1,\} [A-Z]\{1,\} [^A-Z]\{1,\} [A-Z]\{1,\} [^A-Z]\{1,\}\|^[^A-Za-z][^A-Z]*$/!d;/\b[^A-Za-z]\{1\}[A-Z]\{1\}[^A-Za-z]\{1,2\}[A-Z]\{1,2\}\|\b[A-Z]\{3\}[^ A-Z]\{1,\}\|^[A-Z] [A-Z] [A-Z]$/d' infile

you maybe must use like this Smilie

Code:
### justdoit ###
# "find the line more than 3 numbers" or/and "less than 4 characters"
 
#!/bin/bash
 while read -r l
 do
   if [ $(echo "$l" | tr -d '[:alpha:]' | sed 's/ *//g' | wc -c) -gt 4 ] ; then
        `sed -i "/$l/d" infile`
   elif [ $(echo "$l" | tr -d '[:digit:]' | sed 's/ *//g' | wc -c) -lt 5 ] ; then
        `sed -i "/$l/d" infile`
   else
        echo "line has different condition->" `sed -n "/$l/p" infile`
   fi
 done < infile
 more a


regards
ygemici
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting lines that contain spaces in a txt file

I need some help deleting lines in a file that contain spaces. Im sure awk or sed will work but i dont know much about those commands. Any help is appreciated :D (7 Replies)
Discussion started by: r04dw4rri0r
7 Replies

2. Shell Programming and Scripting

Delete first and second lines from .txt

Hi, I have to programming a program in shell script which combine a lot of .txt files. But in all of these files the program had to delete the first both lines. Because I don't know anything about shell script I need your help. Does anyone have a command or a hint, where I can look for? ... (1 Reply)
Discussion started by: mkrol
1 Replies

3. Homework & Coursework Questions

Delete first both lines from .txt

Hi, I have to programming a program in shell script which combine a lot of .txt files. But in all of these files the program had to delete the first both lines. Because I don't know anything about shell script I need your help. Does anyone have a command or a hint, where I can look for? ... (1 Reply)
Discussion started by: mkrol
1 Replies

4. UNIX for Dummies Questions & Answers

Deleting/Removing sentence from .txt

Hi, now i need to remove the entires i inserted into my .txt file. echo -n "Title: " read Title echo -n "Author: " read Author if grep -q "$Title: $Author" "BookDB.txt"; then sed '$Title: $Author' BookDB.txt echo "Book Title '$Title' removed successfully!" ... (6 Replies)
Discussion started by: santonio
6 Replies

5. Shell Programming and Scripting

sed to cp lines x->y from 1.txt into lines a->b in file2.txt

I have one base file, and multiple target files-- each have uniform line structure so no need to use grep to find things-- can just define sections by line number. My question is quite simple-- can I use sed to copy a defined block of lines (say lines 5-10) from filename1.txt to overwrite an... (3 Replies)
Discussion started by: czar21
3 Replies

6. Shell Programming and Scripting

merging two .txt files by alternating x lines from file 1 and y lines from file2

Hi everyone, I have two files (A and B) and want to combine them to one by always taking 10 rows from file A and subsequently 6 lines from file B. This process shall be repeated 40 times (file A = 400 lines; file B = 240 lines). Does anybody have an idea how to do that using perl, awk or sed?... (6 Replies)
Discussion started by: ink_LE
6 Replies

7. Shell Programming and Scripting

Extended replacing of nonspecific strings in text files [beware complicated !]

Well, to make another post at this helpful forum :b::D: I recently tried something like this, I want to replace all those numberings/letters that are located between <string>file://localhost/var/mobile/Applications/ and /Documents/</string> numberings =---- replace with: first... (6 Replies)
Discussion started by: pasc
6 Replies

8. UNIX for Dummies Questions & Answers

find lines in file1.txt not found in file2.txt memory problem

I have a diff command that does what I want but when comparing large text/log files, it uses up all the memory I have (sometimes over 8gig of memory) diff file1.txt file2.txt | grep '^<'| awk '{$1="";print $0}' | sed 's/^ *//' Is there a better more efficient way to find the lines in one file... (5 Replies)
Discussion started by: raptor25
5 Replies

9. Shell Programming and Scripting

Getting lines from .txt file

Hi I have a file with contents: NAMES John carrey williams How can I get all the names and store them in seperate variables(or arrays) please keep in mind that the no. of such names is not known.Three here is a bogus value ~thanks (4 Replies)
Discussion started by: leghorn
4 Replies

10. Shell Programming and Scripting

Deleting Repeating lines from a txt file via script

Hi, I'm having trouble in achieving the following scenario. There is a txt file with thousands of lines and few lines are repeated, which needs to be removed using a script. File.txt 20140522121432,0,12,ram Loc=India From=ram@xxx.com, To=ravi@yyy.com,, 1 2 3 4 . . 30... (18 Replies)
Discussion started by: Gautham
18 Replies
ALCC(1) 							  aMule utilities							   ALCC(1)

NAME
alcc - text based eD2k links calculator for aMule SYNOPSIS
alcc [-p] [-v] <inputfiles_list> alcc [-h] DESCRIPTION
Compute the eD2k links of all the input files given in the <inputfiles_list> (There can be one or more files). [ -p, --parthashes ] Compute and add part hashes to the computed eD2k links. [ -h, --help ] Prints a short usage description. [ -v, --verbose ] Be verbose - show also calculation steps. REPORTING BUGS
Please report bugs either on our forum (http://forum.amule.org/), or in our bugtracker (http://bugs.amule.org/). Please do not report bugs in e-mail, neither to our mailing list nor directly to any team member. COPYRIGHT
aMule and all of its related utilities are distributed under the GNU General Public License. SEE ALSO
alc(1), amuled(1), amulecmd(1), amuleweb(1), cas(1), ed2k(1), wxcas(1), xas(1) AUTHOR
This manpage was written by Vollstrecker <amule@vollstreckernet.de> aMule eD2k links calculator November 2011 ALCC(1)
All times are GMT -4. The time now is 06:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy