Sponsored Content
Top Forums UNIX for Beginners Questions & Answers "Mv" command does not work in loop, but works manually Post 303040717 by andrevol on Tuesday 5th of November 2019 07:51:04 AM
Old 11-05-2019
"Mv" command does not work in loop, but works manually

Hi there, this may be a beginner's error, but I've been unable to find a solution on my own and by googling, and now I am really stuck on it.

I am simply trying to move directories called for example CAT_Run01.ica to a directory with the corresponding number, Run01, in the same directory.

For some reason the loop does not work
Code:
		nrun=`ls -d CAT_Run??.ica | wc -l`							
		for run in `seq 1 $nrun`; do
			mv CAT_Run0$run.ica Run0$run
                done

The "mv" command works manually: if I instead of looping type "run=1", then the line "mv CAT_Run0$run.ica Run0$run" will work and move "CAT_Run01.ica/" to "Run01/". The sequence works, it prints out the correct numbers.

But for some reason, when running the loop, I get the error:
"-bash: 0.ica: command not found"

Best,
Andreas
Psychology student just trying to work with some data

Last edited by vbe; 11-05-2019 at 03:18 PM..
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get Find command work with a variable passing "*" value?

Hi guy, I have a problem to pass a variable containing '*' value to FIND command. below is the script. It doesn't work by submit below command: rmf.sh name '*.txt' or rmf.sh name *.txt I've tried either optn="-name '$2'" or optn="-name $2"., and there is no luck. ### (script... (5 Replies)
Discussion started by: unxuser
5 Replies

2. UNIX for Advanced & Expert Users

sometimes "ps -elf" command doesn't work

when i give "ps -elf" or "ps" system gets hung. if i press "^c" come out from it... pls help..what should i do to get it resolved. thanks CKanth (4 Replies)
Discussion started by: srikanthus2002
4 Replies

3. Shell Programming and Scripting

Silly question - how does the "mv" command work?

I know this may sound really elemental, but I'm trying to figure out if I'm correct. I have a script that moves a file from a temp directory to (what I am calling) a pickup directory. On another machine, I have this "other program" that scans the contents of the pickup directory for a... (5 Replies)
Discussion started by: gseyforth
5 Replies

4. AIX

"/" doesn't work on command prompt for searching commands last typed

When I use "/" to look for a particular command that I typed in the current session it says D02:-/home/user1/temp> /job ksh: /job: not found. D02:-/home/user1/temp> previously it used to fetch all the commands which had job in it.. for example subjob, endjob, joblist etc... may I... (7 Replies)
Discussion started by: meetzap
7 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Red Hat

files having Script which works behind "who" & "w" commands

Dear All, plz print the path of files which have the script of "who" & "w" commands. thnx in advance. (6 Replies)
Discussion started by: saqlain.bashir
6 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Red Hat

"/usr/sbin/hpacucli ctrl all show" command does not work

Dear Concern, We have observed that following command stuck/does not work in some RedHat nodes. Please advise us to troubleshoot the issue. /usr/sbin/hpacucli ctrl all show Note: HP Array Configuration Utility CLI for Linux 64-bit With Best Regards, Md. Abdullah-Al Kauser (3 Replies)
Discussion started by: makauser
3 Replies
OPENVT(1)                                                            Linux 1.x                                                           OPENVT(1)

NAME
openvt - start a program on a new virtual terminal (VT). SYNOPSIS
openvt [-c vtnumber] [OPTIONS] [--] command DESCRIPTION
openvt will find the first available VT, and run on it the given command with the given command options, standard input, output and error are directed to that terminal. The current search path ($PATH) is used to find the requested command. If no command is specified then the environment variable $SHELL is used. OPTIONS -c, --console=VTNUMBER Use the given VT number and not the first available. Note you must have write access to the supplied VT for this to work; -f, --force Force opening a VT without checking whether it is already in use; -e, --exec Directly execute the given command, without forking. This option is meant for use in /etc/inittab. If you want to use this feature in another context, be aware that openvt has to be a session leader in order for -e to work. See setsid(2) or setsid(1) on how to achieve this. -s, --switch Switch to the new VT when starting the command. The VT of the new command will be made the new current VT; -u, --user Figure out the owner of the current VT, and run login as that user. Suitable to be called by init. Shouldn't be used with -c or -l; -l, --login Make the command a login shell. A - is prepended to the name of the command to be executed; -v, --verbose Be a bit more verbose; -w, --wait wait for command to complete. If -w and -s are used together then openvt will switch back to the controlling terminal when the com- mand completes; -V, --version print program version and exit; -h, --help show this text and exit. -- end of options to openvt. NOTE
If openvt is compiled with a getopt_long() and you wish to set options to the command to be run, then you must supply the end of options -- flag before the command. EXAMPLES
openvt can be used to start a shell on the next free VT, by using the command: openvt bash To start the shell as a login shell, use: openvt -l bash To get a long listing you must supply the -- separator: openvt -- ls -l HISTORY
Earlier, openvt was called open. It was written by Jon Tombs <jon@gtex02.us.es or jon@robots.ox.ac.uk>. The -w idea is from "sam". SEE ALSO
chvt(1), doshell(8), login(1) 19 Jul 1996 V1.4 OPENVT(1)
All times are GMT -4. The time now is 03:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy