Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Deleting lines in .txt with nonspecific value Post 302445366 by luis3141 on Sunday 15th of August 2010 07:48:20 PM
Old 08-15-2010
Thanks for your response! but i couldnt get it to work, i tried:

Code:
# sed /[0-9]\{4,\}\|[0-9]\{1\}.*[0-9]\{1\}.*[0-9]\{1\}.*[0-9]\{1\}/d infile

But that didnt change anything, notice that i dont use single quotes cause i dont know how to write them in gnuwin, i press alt+39 and instead of getting " ' " i get something like this " ` " and i get "unknown command", could that be the reason?

And to make it "delete lines with more than 4 numbers" it would be something like these right?

Code:
# sed /[0-9]\{5,\}\|[0-9]\{1\}.*[0-9]\{1\}.*[0-9]\{1\}.*[0-9]\{1\}.*[0-9]\{1\}/d infile

But since i am doing something wrong or the code is missing something it doesn't work.

Then regarding this:
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

I like this code, since this section of the code:

Code:
   if [ $(echo "$l" | tr -d '[:alpha:]' | sed 's/ *//g' | wc -c) -gt 4 ] ; then
        `sed -i "/$l/d" infile`

is a lot simpler than getting the same results on "sed" alone, but i dont have "bash" in my gnuwin32 files, i downloaded it, but can it be used from the gnuwin32 console at all? i couldn't even run the install from the bash folder.


Sorry but as i said, i dont know anything about this, so i can do little on my own.

Last edited by luis3141; 08-15-2010 at 08:56 PM..
 

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
NWBPSET(1)							      nwbpset								NWBPSET(1)

NAME
nwbpset - Create a bindery property or set its value SYNOPSIS
nwbpset [ -h ] [ -S server ] [ -U user name ] [ -P password | -n ] [ -C ] DESCRIPTION
nwbpset Reads a property specification from the standard input and creates and sets the corresponding property. The format is determined by the output of 'nwbpvalues -c'. nwbpset will hopefully become an important part of the bindery management suite of ncpfs, together with 'nwbpvalues -c'. See util/nwbpsecurity for an example. As another example, look at the following command line: nwbpvalues -t 1 -o supervisor -p user_defaults -c | sed '2s/.*/ME/'| sed '3s/.*/LOGIN_CONTROL/'| nwbpset With this command, the property user_defaults of the user object 'supervisor' is copied into the property login_control of the user object 'me'. nwbpvalues -t 1 -o me -p login_control -c | sed '9s/.*/ff/'| nwbpset This command disables the user object me. Feel free to contribute other examples! nwbpset looks up the file $HOME/.nwclient to find a file server, a user name and possibly a password. See nwclient(5) for more information. Please note that the access permissions of $HOME/.nwclient MUST be 600 for security reasons. OPTIONS
-h -h is used to print out a short help text. -S server server is the name of the server you want to use. -U user user is the user name to use for login. -P password password is the password to use for login. If neither -n nor -P are given, and the user has no open connection to the server, nwbpset prompts for a password. -n -n should be given if no password is required for the login. -C By default, passwords are converted to uppercase before they are sent to the server, because most servers require this. You can turn off this conversion by -C. AUTHORS
nwbpset was written by Volker Lendecke. See the Changes file of ncpfs for other contributors. nwbpset 8/7/1996 NWBPSET(1)
All times are GMT -4. The time now is 06:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy