Sponsored Content
Top Forums Shell Programming and Scripting Bash script to process file without regard for case Post 302410740 by manouche on Tuesday 6th of April 2010 06:11:04 PM
Old 04-06-2010
Bash script to process file without regard for case

Hello,

I have a Bash script that processes a text file so that the existing file will look something like this:

Code:
/www/repository/2010/201002231329532/LTLO_0407.pdf
/www/repository/2010/201002231329532/LTLO_0507.pdf
/www/repository/2010/201002231329532/LTLO_0607.pdf
/www/repository/2010/201002231329532/LTLO_0707.pdf
/www/repository/2010/201002231329532/LTLO_0807.pdf

Then the script uses a 'For-Do' loop to copy the files to another directory. Unfortunately, the original text file did not pay attention to case. So, when the copy takes place, some of the files are not recognized because of case and are not copied. Looking around for a solution, I did find the 'shopt -s nocasematch' and stuck it in my script, but it spits out errors.

Can someone give me an idea of how I might copy these files without regard for the case?


Code:
#!/bin/bash

cd /home/docs/wash_dig_arch

shopt -s nocasematch
sed 's/^\([0-9][0-9][0-9][0-9]\)/\/www\/repository\/\1\/\1/'g /home/docs/wash_dig_arch/serials_3_2010.txt > /home/docs/wash_dig_arch/Serials.txt

sleep 1
for x in `cat /home/docs/wash_dig_arch/Serials.txt`
do
cp $x /home/docs/wash_dig_arch/NEWDOCS/SERIALS
done
shopt -u nocasematch


Last edited by vgersh99; 04-06-2010 at 07:23 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies

2. Shell Programming and Scripting

with Regard to Case Statement

I need to check if $1 is A or B I tried the following but it seems its not correct..would appreciate a suggestion ? case "$1" in "A" || "B" ) ;; esac Thanks (4 Replies)
Discussion started by: cosec
4 Replies

3. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

4. Shell Programming and Scripting

Script to Convert Upper case to Lower case

Hi All I have a script which extracts values from a Database (A persons name) and puts it into a variable in my script IE: $NAME However the Value in the DB is all in uppercase and contains the users first name and last name EG: > echo $NAME GRAHAM BOYLE > What I need is only the... (7 Replies)
Discussion started by: grahambo2005
7 Replies

5. Shell Programming and Scripting

bash: closing file descriptors from a process

Below is a test script to illustrate a problem from a larger script I am writing. $ cat /tmp/loggingtest #!/bin/bash lvcreate -s -l 100%FREE -n var-data-snapshot vg00/var-data 2> >(logger -t "loggingtest.crit") 1> >(logger -t "loggingtest.info") sync & wait lvremove -f... (1 Reply)
Discussion started by: jelloir
1 Replies

6. Shell Programming and Scripting

Bash script to Automate the Virtual Host creation process!!

Hi all, This is my sample code in /etc/httpd/conf.d/applications.conf file currently we are creating subdomain mannually for every new subdomain. I want to automate this process througs bash script , how its possible. <VirtualHost *:80> ServerName google.com ServerAlias google.com... (5 Replies)
Discussion started by: anishkumarv
5 Replies

7. Shell Programming and Scripting

Killing a bash process and running the second part of script

I want to run a script that calls remote ssh and if it gets hung, I want to be able to kill that part of the script and run another command in the script for example I have a statement like this: if ]; then export tapes=$(for tape in $(su - nacct -c 'ssh remote1 "cat... (1 Reply)
Discussion started by: newbie2010
1 Replies

8. Shell Programming and Scripting

Bash script to read a file from particular line till required line and process

Hi All, Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool. Wraper script am trying is to do with above metion 2 files. utility tool accepts : a. userinfo file : which contains username b. item file : which... (2 Replies)
Discussion started by: Optimus81
2 Replies

9. Shell Programming and Scripting

Use same file selected in first bash process that has matching digits in it fot the second

In the below portion of a bash script the user selects a file from a directory. select file in $(cd /home/cmccabe/Desktop/NGS/API/5-14-2016/bedtools;ls);do break;done files in directory 123_base_counts.txt 456_base_counts.txt 789_base_counts.txt second portion of bash currently (user... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies
cimreparchive(8)					      System Manager's Manual						  cimreparchive(8)

NAME
cimreparchive - create an archive copy of the CIM Server repository SYNOPSIS
cimreparchive archive_file cimreparchive --help cimreparchive --version DESCRIPTION
The cimreparchive command creates an archive copy of the CIM Server repository in the specified archive_file. The archive copy is assured to contain a consistent repository state even if it is created while the CIM Server is running. The archive_file is created using the tar(1) command. To restore the repository from the archive_file, stop the cimserver, move the active repository files to a different location, use tar(2) to extract the archived repository files, and restart the cimserver. (Note that the repository location is printed when an archive file is created.) Options cimreparchive recognizes the following options: --help Displays the command help message. --version Displays the CIM Server version number. EXIT STATUS
When an error occurs, an error message is written to the standard error stream and a non-zero exit status value is returned. The following exit status values are defined: 0 Success 1 General error 2 Failed to initiate archive operation 3 Archive operation failed SEE ALSO
cimserver(8), tar(1). cimreparchive(8)
All times are GMT -4. The time now is 10:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy