Sponsored Content
Full Discussion: Mv or cp with a . (dot)?
Top Forums Shell Programming and Scripting Mv or cp with a . (dot)? Post 303008379 by Don Cragun on Thursday 30th of November 2017 07:56:35 PM
Old 11-30-2017
Note that the following code:
Code:
c=$(cd ../../bla/bla ; find . -name *.xyz) # Set variable c to filename (./filename.xyz)
c=$(c:3:23) # Remove "./" from c variable's filename
c=.$(c:0:26) # Add a "." to the variable filename

cp ../..bla/bla/*.zyz ./$c # Copy the file and rename it with c variable's name

won't work if no files match the pattern and won't work if more than one file matches the pattern ../../bla/bla/*.xyz. The following should work no matter how many files in that directory match:
Code:
find ../../bla/bla -name '*.xyz' | while read -r c
do	cp "$c" ".${c##*/}"
done

If you want it to keep you informed about what it's doing, either add a set -x to the start of the script or add an echo "$c" before the copy command in the loop.

P.S. Note however that if there is a hidden file in your source directory that ends in .xyz you'll end up creating a file with two leading <period>s in your current working directory.

Last edited by rbatte1; 12-01-2017 at 09:56 AM.. Reason: Change mv to cp & add PS.; rbatte1 added a spce into set-x
This User Gave Thanks to Don Cragun For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

dot files

Hi, everyone. I'm now using rsync command, and please tell me what is the wildcard for below looks like. I want to chose dotfiles, such as .ipod .apple but i don't want to chose . and .. ------------------ .* doesn't work, of course. Thanks, Euler04 (2 Replies)
Discussion started by: Euler04
2 Replies

2. Shell Programming and Scripting

splitting on dot in perl

I am trying to split input that looks like ,2005-09-12 01:45:00.000000,2005-09-12 01:48:18.000000, I want to split on the dot . What I am using is ($ev_time,$rol)=split(/\./),$inputfile; This does not recognize the dot as what I want to split on. (2 Replies)
Discussion started by: reggiej
2 Replies

3. Shell Programming and Scripting

Replacing dot for comma

I wanted to change 34.66 to 34,66. I tried the command: sed 's/./,/' $NUM Where $NUM is a variable with 34.66 value. The output is ,4.66 (2 Replies)
Discussion started by: bdalmeida
2 Replies

4. UNIX for Dummies Questions & Answers

variable name with dot(.)

Hi, Is it possible to declare variable with name having dot(.) in it ? something like gs.test='HELLO' Thanks in advance :) (1 Reply)
Discussion started by: gopalss
1 Replies

5. Shell Programming and Scripting

How to type a dot(.) instead of character?

Hi, I want to connect a Oracle databse through unix shell script. When I will execute a shell script it will ask for user name and password to connect the databsae. At the time of entering the password field value, it willl display the characters like star(*), dot(.) instead of exact... (2 Replies)
Discussion started by: rajesh08
2 Replies

6. Shell Programming and Scripting

Greping numbers with dot in it

Hi, I wanted to create a script what would take two numbers out of two files and add them together, but I got stuck with greping numbers what have a dot in it. So far I have grepped the two lines what include the numbers I need (from both files) to a third file and from that file I try to... (7 Replies)
Discussion started by: mario8eren
7 Replies

7. Shell Programming and Scripting

removing DOT by using perl

Hi Friends, I have a variable which has a number (e.g. 12.1234). I want to remove "." (dot) from that number i.e. 121234 I want to do this using perl. Can you please guide me Thank you Anushree (2 Replies)
Discussion started by: anushree.a
2 Replies

8. Shell Programming and Scripting

How to Removing a dot from a file name?

I need a script that will allow me to rename all of my files in subdir /FilesIn as follows: From kumc_835_111200.RMT.dat to kumc_835_111200RMT.dat kumc_835_111200.KMR.dat to kumc_835_111200KMR.dat .................etc How do I do that whithout doing a sed ... (10 Replies)
Discussion started by: mrn6430
10 Replies

9. Shell Programming and Scripting

List the file with a dot

I am on hp-ux and not able to catch the file with dot using a wild card. $ touch .test $ ls -l .test -rw-r--r-- 1 oracle dba 0 Mar 21 05:20 .test $ ls -l *test *test not found $ ls -la *test *test not found Why i am not able to list the file startign with .... (7 Replies)
Discussion started by: bang_dba
7 Replies
CSS::DOM::Rule(3pm)					User Contributed Perl Documentation				       CSS::DOM::Rule(3pm)

NAME
CSS::DOM::Rule - CSS rule class for CSS::DOM VERSION
Version 0.14 SYNOPSIS
use CSS::DOM::Rule ':all'; # import constants use CSS::DOM; $sheet = new CSS::DOM; $sheet->insertRule('bla blah blah {}'); $rule = $sheet->cssRules->[0]; $rule->type; # STYLE_RULE $rule->cssText; # 'bla blah blah {}' or similar $rule->cssText('p { margin: 0 }'); # replace it $rule->parentStyleSheet; # $sheet DESCRIPTION
This module provides the CSS rule class for CSS::DOM. It implements the CSSRule and CSSUnknownRule DOM interfaces. METHODS
Constructor Only call the constructor on this class to create an 'unknown' rule. You have to call the constructor on a particular subclass to get another type. Normally you do not need to call this directly anyway. (See CSS::DOM's "parse" and "insertRule" methods.) But just in case you do want to call it, here it is: new CSS::DOM::Rule $parent; # unknown rule require CSS::DOM::Rule::Style new CSS::DOM::Rule::Style $parent; # etc. $parent is the parent rule, if the rule is nested, or the parent style sheet otherwise. Object Methods type Returns one of the constants below indicating the type of rule. cssText Returns this rule's CSS code. If you pass an argument, it will be parsed as the new CSS code for this rule (replacing the existing data), and the old value will be returned. This method will die if the replacement CSS code creates a different type of rule. parentStyleSheet This returns the style sheet to which the rule belongs. parentRule This returns the rule's parent rule, if there is one, or an empty list otherwise. There is only a parent rule if this one is nested, e.g., inside a media rule. EXPORTS
The following constants that indicate the type of rule will be exported on request (individually or with the ':all' tag): UNKNOWN_RULE STYLE_RULE CHARSET_RULE IMPORT_RULE MEDIA_RULE FONT_FACE_RULE PAGE_RULE SEE ALSO
CSS::DOM CSS::DOM::Rule::Style CSS::DOM::Rule::Media CSS::DOM::Rule::Page CSS::DOM::Rule::Import perl v5.10.1 2010-12-10 CSS::DOM::Rule(3pm)
All times are GMT -4. The time now is 07:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy