Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Command to read between patterns in a while Post 302990803 by anbu23 on Wednesday 1st of February 2017 07:15:02 AM
Old 02-01-2017
Quote:
Originally Posted by RudiC
I'm afraid sed (alone) can't do that, as it can't calculate nor count. On top, your request is not quite clear - does the term "char" as used by you include digits and punctuation etc, or not? Please specify. If all that is included, try a combination like
Code:
sed ':L; $ {s/\n//g;
            s/<\/test1>/\n/g
            s/<test>\|<tag.>.*<\/tag.>//g
            s/\n$//}
      N; bL
' file |
{ while read LN
     do [ ${#LN} -ge 30 ] && A=$((A+1)) || U=$((U+1))
     done
     echo "0 - 30 char: " $U
     echo "  > 30 char: " $A
}
0 - 30 char:  2
  > 30 char:  1

Just tried for fun Smilie

Code:
$ sed ':L; $ {s/\n//g;
>             s/<\/test1>/\n/g
>             s/<test>\|<tag.>.*<\/tag.>//g
>             s/\n$//}
>       N; bL
> ' f | sed -n "s/^.\{1,30\}$/lt/p" | sed -n "/lt/{$ =;}"
2
$ sed ':L; $ {s/\n//g;
>             s/<\/test1>/\n/g
>             s/<test>\|<tag.>.*<\/tag.>//g
>             s/\n$//}
>       N; bL
> ' f | sed -n "s/^.\{31,\}$/gt/p" | sed -n "/gt/{$ =;}"
1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can we give multiple patterns to a sed command???

HI, I want to know can multiple pattern be given inside a sed statement.. Input: aa_bb_cc.Mar-22-2007 cc_dd_ee.Mar-21-2007 aa_1002985_952.xml aa_bb_032207.txt aa_bb_cc_10002878.dat Output: aa_bb_cc cc_dd_ee aa.xml aa_bb.txt aa_bb_cc.dat (6 Replies)
Discussion started by: kumarsaravana_s
6 Replies

2. Shell Programming and Scripting

Searching patterns in 1 file and deleting all lines with those patterns in 2nd file

Hi Gurus, I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
Discussion started by: toms
4 Replies

3. UNIX for Dummies Questions & Answers

tar/cpio/pax read patterns from stdin

tar has the -T operand for reading patterns from a file. Is there any way to read patterns from stdin, without creating a temp file? I would like to avoid iterating over the archive repeatedly (e.g. with a loop or xargs) as this is a large archive and we're only extracting a small number of... (2 Replies)
Discussion started by: uiop44
2 Replies

4. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

5. Shell Programming and Scripting

to read two files, search for patterns and store the output in third file

hello i have two files temp.txt and temp_unique.text the second file consists the unique fields from the temp.txt file the strings stored are in the following form 4,4 17,12 15,65 4,4 14,41 15,65 65,89 1254,1298i'm able to run the following script to get the total count of a... (3 Replies)
Discussion started by: vaibhavkorde
3 Replies

6. Shell Programming and Scripting

Any way to "alias" file patterns for use in a command?

First, I apologize for my 'noobness' with Linux and the shell. I'm running Ubuntu with zsh as my shell. What I'd like to be able to do is clean up a messy Downloads folder by moving categories of files to different directories with something like: mv dir/$vids dest mv dir/$music dest mv... (5 Replies)
Discussion started by: Apollo33
5 Replies

7. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

8. Shell Programming and Scripting

Find matched patterns and print them with other patterns not the whole line

Hi, I am trying to extract some patterns from a line. The input file is space delimited and i could not use column to get value after "IN" or "OUT" patterns as there could be multiple white spaces before the next digits that i need to print in the output file . I need to print 3 patterns in a... (3 Replies)
Discussion started by: redse171
3 Replies

9. Shell Programming and Scripting

Bash - Find files excluding file patterns and subfolder patterns

Hello. For a given folder, I want to select any files find $PATH1 -f \( -name "*" but omit any files like pattern name ! -iname "*.jpg" ! -iname "*.xsession*" ..... \) and also omit any subfolder like pattern name -type d \( -name "/etc/gconf/gconf.*" -o -name "*cache*" -o -name "*Cache*" -o... (2 Replies)
Discussion started by: jcdole
2 Replies

10. UNIX for Beginners Questions & Answers

Awk/sed command to extract the string between 2 patterns but having some particular value

Hi - i have one file with content as below. ***** BEGIN 123 ***** BASH is awesome ***** END ***** ***** BEGIN 365 ***** KSH is awesome ***** END ***** ***** BEGIN 157 ***** KSH is awesome ***** END ***** ***** BEGIN 7123 ***** C is awesome ***** END ***** I am trying to find all... (4 Replies)
Discussion started by: reldb
4 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 09:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy