Sponsored Content
Top Forums Shell Programming and Scripting Replacing trailing space with single quote Post 302834143 by Yoda on Thursday 18th of July 2013 11:50:53 AM
Old 07-18-2013
[] are metacharacter to match one item in the list.

[ ] matches a blank space. [ ]* means zero or more occurrences of blank space.

From Wikipedia: Regular Expression
Code:
A bracket expression. Matches a single character that is contained within the brackets. 
For example, [abc] matches "a", "b", or "c". [a-z] specifies a range which matches any lowercase letter from "a" to "z". 
These forms can be mixed: [abcx-z] matches "a", "b", "c", "x", "y", or "z", as does [a-cx-z].
The - character is treated as a literal character if it is the last or the first (after the ^) character within the brackets: [abc-], [-abc]. 
Note that backslash escapes are not allowed. The ] character can be included in a bracket expression if it is the first (after the ^) character: []abc].

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing a single quote

Hi there I have a data file like so below 'A/1';'T100002';'T100002';'';'01/05/2004';'31/05/2004';'01/06/2004';'08/06/2004';'1.36';'16';'0.22';'0';'0';'1.58';'0';'0';'0';'0';'0';'0';'clientes\resumen\200405\resumen_T100002_T100002_1.pdf';'';'0001';'S';'20040501';'';'02';'0';'S';'N'... (3 Replies)
Discussion started by: rjsha1
3 Replies

2. Shell Programming and Scripting

replacing single space in argument

I want to write a script which will check the arguments and if there is a single space(if 2 more more space in a row , then do not touch), replace it with _ and then gather the argument so, program will be ran ./programname hi hello hi usa now hello hello so, inside of program,... (7 Replies)
Discussion started by: convenientstore
7 Replies

3. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

4. Shell Programming and Scripting

replacing a quote in some lines with multiple quote fields

i want to replace mistaken quotes in line starting with tag 300 and relocate the quote in the correct position so the input is 223;25 224;20100428064823;1;0;0;0;0;0;0;0;8;1;3;9697;18744;;;;;;;;;;;; 300;X;Event:... (3 Replies)
Discussion started by: wradwan
3 Replies

5. Shell Programming and Scripting

Replace single quote with two single quotes in perl

Hi I want to replace single quote with two single quotes in a perl string. If the string is <It's Simpson's book> It should become <It''s Simpson''s book> (3 Replies)
Discussion started by: DushyantG
3 Replies

6. UNIX for Dummies Questions & Answers

Replacing double spaces with single space

I am looking for a regular expression that uses sed to replace multiple spaces with single spaces on every line where it is not at the start of the line and not immediately before double slashes ('//') or between quotes ("). In its simplest form, it would look like this: sed -e 's# # #g'... (4 Replies)
Discussion started by: figaro
4 Replies

7. Shell Programming and Scripting

Replacing Double Quote in Double Quote incsv file

Hi All , We have source data file as csv file and since data could contain commas ,each attribute is quoted into double quotes.However problem is that some of the attributa data also contain double quotes which is converted to double double quote while creating csv file XLs data : ... (2 Replies)
Discussion started by: Shalini Badal
2 Replies

8. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

9. Shell Programming and Scripting

Replacing Multiple spaces with a single space but excluding few regular expressions

Hi All. Attached are two files. I ran a query and have the output as in the file with name "FILEWITHFOURRECORDS.txt " I didn't want all the spaces between the columns so I squeezed the spaces with the "tr" command and also added a carriage return at the end of every line. But in two... (3 Replies)
Discussion started by: sparks
3 Replies

10. Shell Programming and Scripting

Remove trailing empty spaces within a quote

Platform: Oracle Linux 6.5 I have a file with hundreds of values enclosed in single quotes like below. I want the trailing empty spaces before the ending quote to be removed. Expected output shown below. Can this be done using good old vi editor ? Or should I use sed or awk for this ? $ cat... (4 Replies)
Discussion started by: kraljic
4 Replies
BACKUP_ADDVOLENTRY(8)					       AFS Command Reference					     BACKUP_ADDVOLENTRY(8)

NAME
backup_addvolentry - Defines a volume entry in a volume set SYNOPSIS
backup addvolentry -name <volume set name> -server <machine name> -partition <partition name> -volumes <volume name (regular expression)> [-localauth] [-cell <cell name>] [-help] backup addvole -n <volume set name> -s <machine name> -p <partition name> -v <volume name (regular expression)> [-l] [-c <cell name>] [-h] DESCRIPTION
The backup addvolentry command adds a volume entry definition to the existing volume set named by the -name argument. A volume entry definition can match one or more volumes, depending on the combination of the -server, -partition, and -volumes arguments. For the -server and -partition arguments, provide either o The name of one machine or partition. o The metacharacter expression .* (period and asterisk), which matches every machine name or partition name in the Volume Location Database (VLDB). For the -volumes argument, specify a combination of alphanumeric characters and one or more metacharacters to wildcard part or all of the volume name. OPTIONS lists the acceptable metacharacters. CAUTIONS
It is best to issue this command in interactive mode. If issuing it at the shell prompt, enclose any strings containing metacharacters in double quotes, or escape the metacharacters with other delimiters, to prevent the shell from interpreting them. Adding volume entries to a temporary volume set is possible only within the interactive session in which the volume set was created. OPTIONS
-name <volume set name> Names the volume set to which to add this volume entry definition. The volume set must already exist (use the backup addvolset command to create it). -server <machine name> Defines the set of one or more file server machines that house the volumes in the volume entry. Provide either one fully-qualified hostname (such as "fs1.abc.com") or the metacharacter expression ".*" (period and asterisk), which matches all machine names in the VLDB. -partition <partition name> Defines the set of one or more partitions that house the volumes in the volume entry. Provide either one complete partition name (such as "/vicepa") or the metacharacter expression ".*" (period and asterisk), which matches all partition names. -volumes <volume name> Defines the set of one or more volumes included in the volume entry. Specify the volumes by name, by using any combination of regular alphanumeric characters and one or more of the following metacharacter expressions: . The period matches any single character. * The asterisk matches zero or more instances of the preceding character. Combine it with any other alphanumeric character or metacharacter. [ ] Square brackets around a list of characters match a single instance of any of the characters, but no other characters; for example, "[abc]" matches a single "a" or "b" or "c", but not "d" or "A". This expression can be combined with the asterisk. ^ The caret, when used as the first character in a square-bracketed set, designates a match with any single character except the characters that follow it; for example, "[^a]" matches any single character except lowercase "a". This expression can be combined with the asterisk. A backslash preceding any of the metacharacters in this list makes it match its literal value only. For example, the expression "." (backslash and period) matches a single period, "*" a single asterisk, and "\" a single backslash. Such expressions can be combined with the asterisk (for example, ".*" matches any number of periods). Perhaps the most common metacharacter expression is the period followed by an asterisk (".*"). This expression matches any string of any length, because the period matches any character and the asterisk means any number of that character. As mentioned, it is the only acceptable metacharacter expression for the -server and -partition arguments. In a volume definition it can stand alone (in which case it matches every volume listed in the VLDB), or can combine with regular characters. The following example matches any volume name that begins with the string "user" and ends with "backup": user.*backup -localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. The backup command interpreter presents it to the Backup Server, Volume Server and VL Server during mutual authentication. Do not combine this flag with the -cell argument. For more details, see backup(8). -cell <cell name> Names the cell in which to run the command. Do not combine this argument with the -localauth flag. For more details, see backup(8). -help Prints the online help for this command. All other valid options are ignored. EXAMPLES
The following command adds a volume entry to the volume set called "sys". The entry matches all volumes on any machine or partition whose names begin with the string "sun4x_56" followed by a period: backup> addvolentry sys .* .* sun4x_56..* The following command adds a volume entry to the volume set called "fs2", to match all volumes on the /vicepb partition of file server machine "fs2.abc.com". Because it is issued at the shell prompt, double quotes surround the metacharacters in the -volumes argument. (The command is shown here on two lines only for legibility reasons.) % backup addvolentry -name fs2 -server fs2.abc.com -partition /vicepb -volumes ".*" The chapter in the OpenAFS Administration Guide about configuring the AFS Backup System presents additional examples as well as advice on grouping volumes. PRIVILEGE REQUIRED
The issuer must be listed in the /etc/openafs/server/UserList file on every machine where the Backup Server is running, or must be logged onto a server machine as the local superuser "root" if the -localauth flag is included. SEE ALSO
backup(8), backup_addvolset(8), backup_delvolentry(8), backup_delvolset(8), backup_listvolsets(8) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 BACKUP_ADDVOLENTRY(8)
All times are GMT -4. The time now is 06:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy