Sponsored Content
Full Discussion: sed file rename
Top Forums Shell Programming and Scripting sed file rename Post 302656585 by jennyjones on Friday 15th of June 2012 02:53:45 AM
Old 06-15-2012
sed file rename

Ubuntu -very new to shell scripts/Linux
I have many pictures with "FAMILY", "family" mixed in the file name and not all in the same directory;

I want to remove "family" case insensitive from the filenames;

Code:
find /media/Rock/pics/pics_bak/ -type f "*family*" | sed 's#family##gI'
# works for print but not to rename the file

Code:
find /media/Rock/pics/pics_bak/ -type f -iname "*family*" | rename 's#family##gI'
# error     Having no space between pattern and following word is deprecated at (eval 1) line 1,             <STDIN> line 37.
        Bareword found where operator expected at (eval 1) line 1, near "s#family##gI"

I tried various loops to assign sed result to variable so I can use mv without success

if file pattern is inconsistent and not necessarily in the same directory, am I approaching this the wrong way? I see many search and replace samples but didn't see samples with inconsistent pattern/directory

Last edited by pludi; 06-15-2012 at 01:54 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed (or similar) to rename variable headings

Hello, I'm rather new to the world of regular expressions and sed, though am excited by its possibilities. I have a particular task I'd like to achieve, and have googled the topic quite a bit. However, having found some codes that perform a task very similar to what I'd like to do, I can't for... (2 Replies)
Discussion started by: redseventyseven
2 Replies

2. UNIX for Dummies Questions & Answers

Rename files with sed in an until loop (double post)

I want to change the name of some of my files (mypics-0001, mypics-0002, mypics-0003.....mypics-0240) and I want to double check to see if this code is right: x=0 until do sed 's/mypics\-*/bday/g' done Would this change all of my file names to "bday0001....bday0240"? Please let me... (0 Replies)
Discussion started by: jvpike
0 Replies

3. Shell Programming and Scripting

Rename file using sed command

Greetings, I am very new to the UNIX shell scripting and would like to learn. However, I am currently stuck on how to process the below sample : Filename : DOCabcdef24387987ab90d.xml Pattern "DOC"+any character using and +".xml" And i want to change the second part of that file (any... (20 Replies)
Discussion started by: fanny_tirtasari
20 Replies

4. UNIX for Dummies Questions & Answers

Sed or Awk usage to rename string

I have gotten myself totally lost trying to sort this out and just need some help please.. I will have a multiple directories using the following naming convention with an undetermined number of files in each directory. 9780743582094_05of5_Accountable.wav I need to batch rename all files... (5 Replies)
Discussion started by: glev2005
5 Replies

5. Shell Programming and Scripting

try to batch rename using sed (if this is best)

hi gooday I need some help with a rename I am attempting. I'd like to rename a bunch of files in a folder example list.dat.old to list_N.dat query.dat.old to query_N.dat note the two periods in (.dat.old) to become _N.dat I tried using sed like this ls *.dat.old | sed... (3 Replies)
Discussion started by: johnstrong
3 Replies

6. Shell Programming and Scripting

sed to rename files in a folder - please help with script

Hello, I am new to shell scripting and stuck on renaming files in a folder. The files have the format chp01_00001.wav chp01_00002.wav .... chp02_00001.wav chp02_00002.wav .... but I want them to have the following names: chp_bloomy_00001.wav chp_bloomy_00002.wav chp_bloomy_00003.wav... (8 Replies)
Discussion started by: Bloomy
8 Replies

7. Shell Programming and Scripting

Rename file using sed or awk

I have a filename like 1_DATE_3_4.5_888 and I want to modify the date field (ie the last 4 digits ) alone and remove the last field. Old filename:1_DATE_3_4.5_888 Given date (for eg):120606259532 modified date:120606259899 new filename:1_<modified date>_3.4.5 (14 Replies)
Discussion started by: sandy88
14 Replies

8. UNIX for Dummies Questions & Answers

Rename scripts using xargs/sed

Morning all I've got loads of scripts but the names are too long! I've stuck the list in a flat file (names) and I'm trying to read that in line by line and create the new names (in to directory new) from the list. It looks like this: xargs -n1 -I{} <names cat {} | sed... (1 Reply)
Discussion started by: Grueben
1 Replies

9. UNIX for Dummies Questions & Answers

sed replace to rename each line a file

Have a file in this format This is line one ; line_one This is line two ; line_two This is line three ; line_three This is line four ; line four. I'm trying to make each line a new file called line_one line_two line_three line_four. Tried using split -1 but then I'm back needing to rename... (3 Replies)
Discussion started by: jimmyf
3 Replies

10. Shell Programming and Scripting

sed to rename files in bash loop

I am trying to use sed to rename all .txt files in /home/cmccabe/test. However, I am getting an error that I seems to be putting the files in a new directory s, instead of in the original. Thank you :). bash # rename classified cd /home/cmccabe/test pattern2_old="_classify"... (2 Replies)
Discussion started by: cmccabe
2 Replies
ALTER OPERATOR 
FAMILY(7) PostgreSQL 9.2.7 Documentation ALTER OPERATOR FAMILY(7) NAME
ALTER_OPERATOR_FAMILY - change the definition of an operator family SYNOPSIS
ALTER OPERATOR FAMILY name USING index_method ADD { OPERATOR strategy_number operator_name ( op_type, op_type ) [ FOR SEARCH | FOR ORDER BY sort_family_name ] | FUNCTION support_number [ ( op_type [ , op_type ] ) ] function_name ( argument_type [, ...] ) } [, ... ] ALTER OPERATOR FAMILY name USING index_method DROP { OPERATOR strategy_number ( op_type [ , op_type ] ) | FUNCTION support_number ( op_type [ , op_type ] ) } [, ... ] ALTER OPERATOR FAMILY name USING index_method RENAME TO new_name ALTER OPERATOR FAMILY name USING index_method OWNER TO new_owner ALTER OPERATOR FAMILY name USING index_method SET SCHEMA new_schema DESCRIPTION
ALTER OPERATOR FAMILY changes the definition of an operator family. You can add operators and support functions to the family, remove them from the family, or change the family's name or owner. When operators and support functions are added to a family with ALTER OPERATOR FAMILY, they are not part of any specific operator class within the family, but are just "loose" within the family. This indicates that these operators and functions are compatible with the family's semantics, but are not required for correct functioning of any specific index. (Operators and functions that are so required should be declared as part of an operator class, instead; see CREATE OPERATOR CLASS (CREATE_OPERATOR_CLASS(7)).) PostgreSQL will allow loose members of a family to be dropped from the family at any time, but members of an operator class cannot be dropped without dropping the whole class and any indexes that depend on it. Typically, single-data-type operators and functions are part of operator classes because they are needed to support an index on that specific data type, while cross-data-type operators and functions are made loose members of the family. You must be a superuser to use ALTER OPERATOR FAMILY. (This restriction is made because an erroneous operator family definition could confuse or even crash the server.) ALTER OPERATOR FAMILY does not presently check whether the operator family definition includes all the operators and functions required by the index method, nor whether the operators and functions form a self-consistent set. It is the user's responsibility to define a valid operator family. Refer to Section 35.14, "Interfacing Extensions To Indexes", in the documentation for further information. PARAMETERS
name The name (optionally schema-qualified) of an existing operator family. index_method The name of the index method this operator family is for. strategy_number The index method's strategy number for an operator associated with the operator family. operator_name The name (optionally schema-qualified) of an operator associated with the operator family. op_type In an OPERATOR clause, the operand data type(s) of the operator, or NONE to signify a left-unary or right-unary operator. Unlike the comparable syntax in CREATE OPERATOR CLASS, the operand data types must always be specified. In an ADD FUNCTION clause, the operand data type(s) the function is intended to support, if different from the input data type(s) of the function. For B-tree comparison functions and hash functions it is not necessary to specify op_type since the function's input data type(s) are always the correct ones to use. For B-tree sort support functions and all functions in GiST, SP-GiST and GIN operator classes, it is necessary to specify the operand data type(s) the function is to be used with. In a DROP FUNCTION clause, the operand data type(s) the function is intended to support must be specified. sort_family_name The name (optionally schema-qualified) of an existing btree operator family that describes the sort ordering associated with an ordering operator. If neither FOR SEARCH nor FOR ORDER BY is specified, FOR SEARCH is the default. support_number The index method's support procedure number for a function associated with the operator family. function_name The name (optionally schema-qualified) of a function that is an index method support procedure for the operator family. argument_type The parameter data type(s) of the function. new_name The new name of the operator family. new_owner The new owner of the operator family. new_schema The new schema for the operator family. The OPERATOR and FUNCTION clauses can appear in any order. NOTES
Notice that the DROP syntax only specifies the "slot" in the operator family, by strategy or support number and input data type(s). The name of the operator or function occupying the slot is not mentioned. Also, for DROP FUNCTION the type(s) to specify are the input data type(s) the function is intended to support; for GiST, SP-GiST and GIN indexes this might have nothing to do with the actual input argument types of the function. Because the index machinery does not check access permissions on functions before using them, including a function or operator in an operator family is tantamount to granting public execute permission on it. This is usually not an issue for the sorts of functions that are useful in an operator family. The operators should not be defined by SQL functions. A SQL function is likely to be inlined into the calling query, which will prevent the optimizer from recognizing that the query matches an index. Before PostgreSQL 8.4, the OPERATOR clause could include a RECHECK option. This is no longer supported because whether an index operator is "lossy" is now determined on-the-fly at run time. This allows efficient handling of cases where an operator might or might not be lossy. EXAMPLES
The following example command adds cross-data-type operators and support functions to an operator family that already contains B-tree operator classes for data types int4 and int2. ALTER OPERATOR FAMILY integer_ops USING btree ADD -- int4 vs int2 OPERATOR 1 < (int4, int2) , OPERATOR 2 <= (int4, int2) , OPERATOR 3 = (int4, int2) , OPERATOR 4 >= (int4, int2) , OPERATOR 5 > (int4, int2) , FUNCTION 1 btint42cmp(int4, int2) , -- int2 vs int4 OPERATOR 1 < (int2, int4) , OPERATOR 2 <= (int2, int4) , OPERATOR 3 = (int2, int4) , OPERATOR 4 >= (int2, int4) , OPERATOR 5 > (int2, int4) , FUNCTION 1 btint24cmp(int2, int4) ; To remove these entries again: ALTER OPERATOR FAMILY integer_ops USING btree DROP -- int4 vs int2 OPERATOR 1 (int4, int2) , OPERATOR 2 (int4, int2) , OPERATOR 3 (int4, int2) , OPERATOR 4 (int4, int2) , OPERATOR 5 (int4, int2) , FUNCTION 1 (int4, int2) , -- int2 vs int4 OPERATOR 1 (int2, int4) , OPERATOR 2 (int2, int4) , OPERATOR 3 (int2, int4) , OPERATOR 4 (int2, int4) , OPERATOR 5 (int2, int4) , FUNCTION 1 (int2, int4) ; COMPATIBILITY
There is no ALTER OPERATOR FAMILY statement in the SQL standard. SEE ALSO
CREATE OPERATOR FAMILY (CREATE_OPERATOR_FAMILY(7)), DROP OPERATOR FAMILY (DROP_OPERATOR_FAMILY(7)), CREATE OPERATOR CLASS (CREATE_OPERATOR_CLASS(7)), ALTER OPERATOR CLASS (ALTER_OPERATOR_CLASS(7)), DROP OPERATOR CLASS (DROP_OPERATOR_CLASS(7)) PostgreSQL 9.2.7 2014-02-17 ALTER OPERATOR FAMILY(7)
All times are GMT -4. The time now is 08:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy