First off, sorry for the assumption - I'm still new here, and trying hard not to break any rules myself!
Here is some code that I've thrown together that should resolve your issue (no guarantees!)
NOTE: I did not include directory creation to this script. You can do it, but I didn't think to include it before firing it up here.
Code:
#!/usr/bin/csh
# Here are the variables that you will need to change:
################################################################################
set number_of_files = 23 # This is the number of files that you expect
# to store in each directory
set source_dir = /tmp/testing # You'll change this to your source directory
set target_dir = /tmp/folder_ # This is the prefix that you'll use for your
# folder tree. You'll likely wish to change it
# Here are the 'static' variables that you will not change:
################################################################################
#this number will increment the count cap
set count = 0
#iteration counters
set folder_counter = 1 # Starts at one, such that multiplication issues don't arise
set counter = 0
# Get your list of files - I'm taking it from an ls -tr
# This provides an historic list, with the oldest files first
foreach file ( `ls -tr $source_dir` )
@ counter = $counter + 1
@ count = $number_of_files * $folder_counter #First time 'round, this is 3, then 6
# First, check to see if you should move on to the next folder or not...
# - adding a 'move' request to ensure that the file is not skipped
if ($counter > $count) then
@ folder_counter++
mv $source_dir/$file $target_dir$folder_counter
endif
# Since you didn't need to increment the folder_counter - move the file as if nothing happened...
if ($counter <= ($count)) then
mv $source_dir/$file $target_dir$folder_counter
endif
end
Please let me know if it works. I'm sure that there are other MUCH MORE elegant solutions
edit:changed a comment (wrong comment included in paste)
I have a folder that contains say 50 files in a sequential order:
cdf_1.txt
cdf_2.txt
cdf_3.txt
cdf_3.txt
.
.
.
cdf_50.txt.
I need to merge these files in the same order into a single tab delimited file.
I used the following shell script:
for x in {1..50};
do cat cdf_${x}.txt >>... (3 Replies)
Condition1;
If NPID and IndID of both input1 and input2 are same take all the vaues relevant to them and print together as output
Condition2;
IDNo in output: Take the highly repeated same letter of similar NPID-IndID as *1*
Second highly repeated same letter... (0 Replies)
Hello,
I am new to shell scripting and I need your help.
I have found similar scripts in the forum but I need further assistance.
I am building a script to use hourly in cron to mailx me if the number of files in a path is less than e.g 100
I have started with the following:
#!/bin/sh... (2 Replies)
Hi ,
I want to write a simple script.
I have two files
file1:
BCSpeciality
Backend
CB
CBAPQualDisp
CBCimsVFTRCK
CBDSNQualDisp
CBDefault
CBDisney
CBFaxMCGen
CBMCGeneral
CBMCQualDisp
file2:
CSpeciality
Backend (8 Replies)
I am trying to separate a specific pattern match into separate files. Sometimes there is only one pattern match, but other times there could be multiple (up to 6 or 8). Pattern is as follows - its starts with NYZ or VTZ and ends with $$. Again looking to get those blocks of data from one big... (17 Replies)
HI guys,
Could you help me writing a simple version control script for a text files.
the format could be
./version_control <file(s)> (I want it to be able to work with more than 1 file at the same time)
commands are add and get, add means you add new file(s) to the archive, get means you... (4 Replies)
Hi all,
I'm trying to get a bash script working for a program (bowtie) which takes a list of input files (*.fastq) and assembles them to an output file (outfile.sam). All the .fastq files are in one folder in my home directory (~/infiles).
The problem is that the 'bowtie' requires that... (7 Replies)
I have a file Map.hh shown below. I want to put the two classes Phase and Map in two different files Phase.hh and Map.hh. I have forward declaration before the Map class. How can I tackle this situation?
//////////////////////////////////////////////////////////////////////////
#ifndef... (3 Replies)
Hi All,
I need help for doing the following.
I have a input file like:
aaaaaaaaaabbbbbbbbbbbbbbbbbbbb
cccbbbbbaaaaaadddddaaaabbbbbbb
now I am trying to generate a output csv file where i will have for e.g.
0-3 chars of each line as the first column in the csv, 4-10 chars of the line as... (3 Replies)
Discussion started by: babom
3 Replies
LEARN ABOUT SUSE
source
source(n) Tcl Built-In Commands source(n)
__________________________________________________________________________________________________________________________________________________NAME
source - Evaluate a file or resource as a Tcl script
SYNOPSIS
source fileName
source -encoding encodingName fileName |
_________________________________________________________________DESCRIPTION
This command takes the contents of the specified file or resource and passes it to the Tcl interpreter as a text script. The return value
from source is the return value of the last command executed in the script. If an error occurs in evaluating the contents of the script
then the source command will return that error. If a return command is invoked from within the script then the remainder of the file will
be skipped and the source command will return normally with the result from the return command.
The end-of-file character for files is "32" (^Z) for all platforms. The source command will read files up to this character. This
restriction does not exist for the read or gets commands, allowing for files containing code and data segments (scripted documents). If
you require a "^Z" in code for string comparison, you can use "