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
it(8)							      System Manager's Manual							     it(8)

NAME
it - configure a system after installation SYNOPSIS
/sbin/it DESCRIPTION
The it program executes scripts before transferring control of the system to the user, typically before the first user logs in. The it program executes programs that collect information such as system name, passwords, timezone, and current date. A system can be in a run level at any given time; each run level has a specific group of processes that run at that level. The init program operates in one of four run levels: 0, s, 2, or 3. The run level changes when init is invoked by a privileged user. The it program is run from /etc/inittab whenever the system is booted or rebooted, or when a level transition occurs for some other reason, such as within init3. The it program first determines which run level the system is coming up under. Next it turns on shared libraries and swap and then searches for any /sbin/it.d/run-level directories, where run-level names a system run level; for example, 2.d, 3.d, 23.d, and so forth. If any such directories exist, it collects the names of all files in those directories. These files are typically links to files in the /sbin/it.d/bin directory and are created beforehand by itruns(8). After collecting the file names, it sorts them, eliminates duplicate references, orders the names as specified by the data file /sbin/it.d/data/options.mask, executes the files, and finally removes the files it executed. After all the files collected from the run level directories have been handled, it exits. The /sbin/it.d/data/options.mask file contains a single line with a list of file names separated by colons. The it command executes col- lected files in the order in which they appear from left to right in the options.mask file. Programs not listed in the options.mask file are executed after those defined in options.mask. These "unspecified" programs are run in the order into which they were initially sorted; that order is controlled by the LC_COLLATE environmental variable and the specifications in the /usr/lib/nls/loc/locale files. FILES
Specifies execution priorities of files to be run by it Files to be linked by itruns(8) for execution by it SEE ALSO
Commands: init(8), itruns(8), rc0(8), rc2(8), rc3(8), who(1) it(8)
All times are GMT -4. The time now is 05:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy