Sponsored Content
Top Forums Shell Programming and Scripting SED (regular expression) problem --- Post 302421830 by alister on Sunday 16th of May 2010 03:33:48 PM
Old 05-16-2010
Hello, bluesmodular, and welcome to the forums.

Using ls to generate the for loop's list is often a poor approach. If there are any IFS characters (by default, space, tab, and newline) in the resulting filenames, they will be mangled. Often, when making use of some of ls' options (recursive listing, for example), this shortcoming is disregarded if troublesome filenames aren't expected. However, in this particular case, ls is completely unnecessary; you can generate a list of the necessary files with a safe, simple glob.

As for editing each file in place, you can do so with ed:
Code:
half=....
bulksize=....
for i in */run_example; do
    printf '187s/= [^,]*/= %s/\nwq\n' "$bulksize" | ed -s "$i"
    half=....
    bulksize=....
done

Regards,
Alister
This User Gave Thanks to alister For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular expression with sed

Hi, I'm trying following:echo "test line XA24433 test" | sed 's/.*X\(.*\)/X\1/' XA24433 test While I want the output as: XA24433 I want to grab the words starting with letter X till the next space, this word can be anywhere in the line. (9 Replies)
Discussion started by: nervous
9 Replies

2. Shell Programming and Scripting

Regular expression with SED

Hi! I'm trying to write a regexp but I have no luck... I have a string like this: param1=sometext&param2=hello&param3=bye Also, the string can be simply: param2=hello I want to return the value of param2: "hello". How can I do this? Thanks. (3 Replies)
Discussion started by: GagleKas
3 Replies

3. Shell Programming and Scripting

Regular expression (sed)

Hi I need to get text that are within "" For example File: asdasd "test test2" sadasds asdda asdasd "demo demo2" Output: test test2 demo demo2 Any help is good Thank you (12 Replies)
Discussion started by: blito_loco
12 Replies

4. Shell Programming and Scripting

sed regular expression help

please consider this: echo "11111*X*005010X279~ST*270*1111111*005010X279~BHT*0011*11" | sed 's/.*\(005010X(\d)(\d)(\d)*\).*$/\1/'i'm searching for first occurrence of 005010X while leaving rest of characters out. :confused: any tips? thnx in advance guys. (7 Replies)
Discussion started by: grep01
7 Replies

5. UNIX for Dummies Questions & Answers

Regular Expression In Sed

Hi , I am learing sed echo abc 123 def 456 | sed 's|\(*\) \(*\)|\1|' is returning abc def 456 i was hoping abc def "\1" should only print the occurence of the first pattern but according to my understanding it is just removing the first occurence of the second pattern... (7 Replies)
Discussion started by: max_hammer
7 Replies

6. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

7. Shell Programming and Scripting

Help with sed regular expression

Hi all, I want to get a substring from a string based on given delimiter, for example: str="foo|bar|baz" with delimiter "|", I want to get one substring at each time with the order number the substring in the whole string, given 1 to get "foo", given 2 to get "bar", given 3 to get "baz", I... (2 Replies)
Discussion started by: Roy987
2 Replies

8. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

9. Shell Programming and Scripting

I am learning regular expression in sed,Please help me understand the use curly bracket in sed,

I am learning SED and just following the shell scripting book, i have trouble understanding the grep and sed statement, Question : 1 __________ /opt/oracle/work/antony>cat teledir.txt jai sharma 25853670 chanchal singhvi 9831545629 anil aggarwal 9830263298 shyam saksena 23217847 lalit... (7 Replies)
Discussion started by: Antony Ankrose
7 Replies
cueprint(1)						      General Commands Manual						       cueprint(1)

NAME
cueprint - report disc and track infomation from a CUE or TOC file SYNOPSIS
cueprint [ { -i format | --input-format=format } { -n number | --track-number=number } { -d template | --disc-template=template } { -t tem- plate | --track-template=template } ] [ file ... ] cueprint --help DESCRIPTION
cueprint reports disc and track information from CUE and TOC files, which are typically created by compact disc ripping software. By default, cueprint reports a default set of disc information, and a default set of information for each track on the disc. With options, the report can be restricted to a specific track, and the presentation of the disc and track information can be extensively customized using printf(3)-style format strings (referred to here as 'templates' to avoid confusion with the concept of file format). All characters in a template are reproduced as-is in the output except for conversions (which begin with '%') and escapes (which begin with ''). If no filenames are specified, cueprint reads from standard input, and an input format option must be specified. If one or more filenames is provided, but the input format option is not specified, the input format will be guessed based on each file's suffix (e.g., .cue or .toc). This heuristic is case-insensitive. Conversions A conversion has the form '%[flags][width][.precision]type'. flags may be zero or more of the following: Character Meaning ----------------------------------------------------------- - left-justify expansion + place sign before numbers ' ' (space) place a blank space before a positive number 0 pad numbers with zeroes width is the minimum field width. precision is the maximum width for strings. type is a single character which specifies the conversion type -- apart from %, it is the only mandatory part of the conversion. The available conversion types are presented in the table below; disc conversion types are presented in the left half of the table, and track conversion types in the right half. Disc template expansion characters are valid for both disc and track templates. Character Conversion Character Conversion ---------------------------------------------------------------- A album arranger a track arranger C album composer c track composer G album genre g track genre i track ISRC M album message m track message N number of tracks n track number P album performer p track performer S album songwriter T album title t track title U album UPC/EAN u track ISRC (CD-TEXT) Any other character used as a conversion type expands to itself. This is how a literal percent sign is placed in the template; i.e., '%%' expands to '%'. Escapes The recognized escapes are all single characters, and listed in the table below. Escape Sequence Expansion ---------------------------------- a alert (bell)  backspace f formfeed newline carriage return horizontal tab v vertical tab null Any other character used after the '' in an escape sequence expands to itself. This is how a literal escape character is placed in the template; i.e., '\' expands to ''. OPTIONS
-d template, --disc-template=template set disc template (see TEMPLATE EXPANSION) -h, --help displays a usage message and exits. -i format, --input-format=format sets the expected format of the input file(s) to format, which must be either cue or toc. -n number, --track-number=number only print track information for a single track. The default is to print information for all tracks. -t template, --track-template=template set track template (see TEMPLATE EXPANSION) EXIT STATUS
cueprint exits with status zero if it successfully reports information from each input file, and nonzero if there were problems. EXAMPLES
To display disc and track information (using the default template for both): % cueprint album.cue To print the number of tracks in a CUE file: % cueprint -d '%N ' album.cue AUTHOR
Cuetools was written by Svend Sorensen. Branden Robinson contributed fixes and enhancements to the utilities and documentation. SEE ALSO
cuebreakpoints(1), cueconvert(1), printf(3) cueprint(1)
All times are GMT -4. The time now is 03:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy