Pass grep's Output to mv?

Thread Tools Search this Thread
# 8  
What problem? You said it worked.

If noglob was really on, it couldn't have worked.
# 9  
It worked after I changed the target path from a regex to a simple wildcard. It did not work when I first copy/pasted your line.
# 10  
Regexes don't work there, period. If you want it to expand inside the shell itself instead of using grep, you have to use globs.
This User Gave Thanks to Corona688 For This Post:
# 11  
Originally Posted by Corona688
Regexes don't work there, period. If you want it to expand inside the shell itself instead of using grep, you have to use globs.
I'm going to have to read up on globbing because I'm not clear on exactly what that means. But I reset that noglob option, so I will be able to experiment. If I hadn't happened to check the bash version number, I would've been in for some frustration. I don't think I would've ever thought to check the shell options.
Slowly, but surely...
# 12  
Originally Posted by sudon't
I'm going to have to read up on globbing because I'm not clear on exactly what that means.
A glob is like a regular expression, but simplified. A glob has no range specifiers, i.e. A* does not mean "zero or more A's", it means "A followed by zero or more characters".

It has the following special characters and syntax:
  • *: Zero or more of any character.
  • ?: Any single character.
  • [a-z]: regex-like character ranges.

Another thing is, globs must match the entire filename. regexes match as long as they're found somewhere inside the string.
# 13  
Your original code paste shows

xargs -J % mv % ....

Shouldn't it be -I instead of -J in there?

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Can't pass a variable representing the output of lsb_release to a docker dontainer

I don't know why, but the rendering of my code mucks up the spacing and indentation, despite being correct in the original file. I'm having issues getting the following script to run (specifically the nested script at the end of the docker command near the end of the script; I think I'm not passing... (2 Replies)
Discussion started by: James Ray
2 Replies

2. Homework & Coursework Questions

How to Dynamically Pass Parameter to plsql Function & Capture its Output Value in a Shell Variable?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 2. Relevant commands, code, scripts, algorithms: #! /bin/ksh v="ORG_ID" ... (2 Replies)
Discussion started by: sujitdas2104
2 Replies

3. Shell Programming and Scripting

Pass ls command output to diff

Hi , Can some one help me how to pass ls command output to diff command ex : - ls *.xml will return files which have time stamps abc-<time-stamp>.xml xyz-<time-stamp>.xml diff abc-<time-stamp>.xml xyz-<time-stamp>.xml >> newfile.txt we need to... (9 Replies)
Discussion started by: techie_09
9 Replies

4. Shell Programming and Scripting

Need to pass Oracle SQL output to Linux and back... Help!

Hi all, Hopefully you can help. This is what I'm trying to achieve: Obtain a list of usernames out of an Oracle Database Based on this list, link each username with an Oracle Internet Directory (OID) GUID Using the username and GUID perform a database update for all users Here are the... (7 Replies)
Discussion started by: exm
7 Replies

5. Shell Programming and Scripting

cannot pass a echo output to a variable in bash

Hi, I have a problem with passing a echo output into a variable in bash file='1990.tar' NAME='echo $file | cut -d '.' -f1'; echo $NAME the result is echo $file | cut -d . -f1 however with this one,#!/bin/bash file='1990.tar' echo $file | cut -d '.' -f1 the result is what I... (2 Replies)
Discussion started by: 1988PF
2 Replies

6. Shell Programming and Scripting

Simple ways to pass variations to grep

can someone please show me a better way (if there is one), to grep out all variations (upper and small case letters) from a file? egrep "(panic|error|failed|fail|FAIL)" /var/log/messages I'm interested in finding any string that may indicate somethings wrong with ANY part of a system. so, if... (6 Replies)
Discussion started by: SkySmart
6 Replies

7. Shell Programming and Scripting

How to Pass the Output Values from the PL/SQL Procedure to Shell Script?

hi, Could anyone tell me how to pass the output values of the PL/SQL procedure to Shell script and how to store that values in a shell script variable... Thanks in advance... (5 Replies)
Discussion started by: funonnet
5 Replies

8. Shell Programming and Scripting

Pass input and output file as parameter to awk script

Hi, i am new to awk. I am using csv2pipe script(shown below) BEGIN { FS=SUBSEP; OFS="|" } { result = setcsv($0, ",") print } # setcsv(str, sep) - parse CSV (MS specification) input # str, the string to be parsed. (Most likely $0.) # sep, the separator between the values. # #... (6 Replies)
Discussion started by: bhaskarjha178
6 Replies

9. Shell Programming and Scripting

[csh] How to capture output from a command and pass it on to a variable?

Hi there! I'm trying to write a script that will capture output from a command and assign it to a variable. Let's say, for example, I'd like to catch from inside the script whatever the following command outputs: ls *.aaa and put it into a variable "listoffiles". What I tried was: set... (3 Replies)
Discussion started by: machinogodzilla
3 Replies

10. Shell Programming and Scripting

how to pass variable to grep?

Hi I have a such conditional: SPAMH="it is SPAM" if grep -q $SPAMH $NMDIR/$mail; then SPAMHFLAG=1 else SPAMHFLAG=0 fi And grep doesn't catch this string, even it exists there. I think it's a problem with passing $SPAMH to grep. I tried... (2 Replies)
Discussion started by: xist
2 Replies

Featured Tech Videos