Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Adding an extension to a group of filenames Post 49759 by Optimus_P on Friday 9th of April 2004 03:32:54 PM
Old 04-09-2004
Quote:
Originally posted by pepintheshort
Optimus,

I appreciate the insight, but I think you're missing my point. My problem is with the regular expression I posted above. I need help matching the metacharacters.

If you had read my initial post, you'll also see that I am hesitant to use mv or cp to rename the files because (without the "for" loop) it will only mv one file at a time. Since I am a relative newcomer to creating a shell script, I need more information than just one brief phrase - details are extremely critical. So, if you think I should use a "for" loop, why not post a sample of the code - all of the code, not "do cool stuff here" - so that it helps fix my problem. Other new people might read this post too and possibly learn from it.

If you don't know the answer to my question, I would appreciate you not wasting my time, and letting someone else answer - even if its to point me to an FAQ where this type of question may have already been answered. (I did search the BBS briefly before posting and did not match what I was looking for.)

snip.. My files have the names "projectaa", "projectab", "projectac", etc. What I want to do is add the extension ".txt" to each file.../snip
These forums are to help you think of the answer. Not to do the work for you. WE DO NOT FIX YOUR PROBLEMS. WE HELP YOU FIX YOUR PROBLEMS. we are here to help you help yourself and in doing so you become a better coder/admin/hobbiest/l33t d00d

The concept of a forloop it to continue the loop for the # of arugments it is passed.

I am very capable of supplying this answer. I am chooseing to not supply the full answer but instead challenge you to come up with it on your own with some supportive outside assistance.

your sed command is completely unneeded for this request.
If you wrote the sed command why dont you explane to me exactly what you are doing with it.

if all you wanted to know was how to escape metachar then why didnt you just say that to begin with.
To escape metachar use a backslash.

also note in your orig post you did not say you are hesitent to use the move or copy command.

i gave you the framework. you need to work a bit harder at completeing the missing puzzle pieces instead of comming here to complane about not getting what you want when you wanted it.

Last edited by Optimus_P; 04-09-2004 at 04:38 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading filenames with extension .xml

Hi, I want to write a script to read all the filenames with extension .xml in a directory and pass the name of the file, one by one, to another function. Please help me out. Regards. Saurabh (3 Replies)
Discussion started by: bhalotias
3 Replies

2. UNIX for Dummies Questions & Answers

removing the extension from all filenames in a folder

Hi there, I'm pretty new to UNIX and have tried trawling through this forum to find an answer to what I want to try to do, which I'm sure is very simple but I don't know how to do it. What I have a a folder that contains multiple files that I have copied from Windows and I want to remove the... (5 Replies)
Discussion started by: johnmcclintock
5 Replies

3. Shell Programming and Scripting

Help with adding to tar filenames

Hi there, i have been working on a backup script and have it just about working, the only problem im left with is that my filenames for my backups are all the same are replacing one another when backing up. currently i have BACKUP_FILE=backup_$(date +%d%m%y).tgz but would like something like... (2 Replies)
Discussion started by: Swinton
2 Replies

4. Shell Programming and Scripting

How to split a file with adding sequence number and extension.

I have a file name -HRCFTSIN05PLA1602100430444444 my requirement is to split the file in 10000 count each file and to add sequence number.rch at the end of each file. output should be in this format HRCFTSIN05PLA160210043044444401.rch HRCFTSIN05PLA160210043044444402.rch... (4 Replies)
Discussion started by: abhigrkist
4 Replies

5. Shell Programming and Scripting

Adding lines to files based on file extension

I have posted this before but did not get many replies, so here it goes again. I have several files name like this If the file extension is 1a, I woould like to add at the beggining of the file the following sequence If the file extension is 1b, thn the entry that should be added is the next... (2 Replies)
Discussion started by: Xterra
2 Replies

6. Shell Programming and Scripting

Adding the data before file extension

HI , I have a file with multiple lines like below, I need to check on column starting with #prototype if it has the .Number.txt extension do nothing else add 1.txt extension. Source data Jdbc_app_data :- sample data #prototype= sample data from test.1.txt application_id=122135... (4 Replies)
Discussion started by: gaur.deepti
4 Replies

7. Shell Programming and Scripting

Adding number before file extension

Hi , I have a file which has a line starts with $segment_name and has the below data source data $Segment_Name = 123.ABC.123.01.txt $Segment_Name = 123.ABC.ABC.txt $Segment_Name = 123.ABC.12A3.txtMy target data should be $Segment_Name = 123.ABC.123.01.txt $Segment_Name =... (2 Replies)
Discussion started by: shruthidwh
2 Replies

8. AIX

Adding a Volume Group to an HACMP Resource Group?

Hi, I have a 2 node Cluster. Which is working in active/passive mode (i.e Node#1 is running and when it goes down the Node#2 takes over) Now there's this requirement that we need a mount point say /test that should be available in active node #1 and when node #1 goes down and node#2 takes... (6 Replies)
Discussion started by: aixromeo
6 Replies

9. Shell Programming and Scripting

change filenames but not extension

I have a filename with a bunch of periods that I want to replace with underscores, but I don't want to change the extension. Ex: I want file.test1.f-1.fig.eps to be file_test1_f-1_fig.eps Using awk, the following line will replace ALL periods with underscores, but I want to leave the... (2 Replies)
Discussion started by: erinbot
2 Replies

10. Shell Programming and Scripting

How to remove filenames having the same extension.?

hi, i have a directory which contains some files and a subdirectory. i am writing only the files names to a file using the below code. ls -ltr | grep "^-" | awk '{print $NF}' > /home/file_list$$ cat /home/file_list$$ s1_abc.txt s2_def.xls s3_def.xls as you can see there is one .txt... (7 Replies)
Discussion started by: Little
7 Replies
GRPCK(8)						    System Management Commands							  GRPCK(8)

NAME
grpck - verify integrity of group files SYNOPSIS
grpck [options] [group [ shadow ]] DESCRIPTION
The grpck command verifies the integrity of the groups information. It checks that all entries in /etc/group and /etc/gshadow have the proper format and contain valid data. The user is prompted to delete entries that are improperly formatted or which have other uncorrectable errors. Checks are made to verify that each entry has: o the correct number of fields o a unique and valid group name o a valid group identifier (/etc/group only) o a valid list of members and administrators o a corresponding entry in the /etc/gshadow file (respectively /etc/group for the gshadow checks) The checks for correct number of fields and unique group name are fatal. If an entry has the wrong number of fields, the user will be prompted to delete the entire line. If the user does not answer affirmatively, all further checks are bypassed. An entry with a duplicated group name is prompted for deletion, but the remaining checks will still be made. All other errors are warnings and the user is encouraged to run the groupmod command to correct the error. The commands which operate on the /etc/group and /etc/gshadow files are not able to alter corrupted or duplicated entries. grpck should be used in those circumstances to remove the offending entries. OPTIONS
The -r and -s options cannot be combined. The options which apply to the grpck command are: -h, --help Display help message and exit. -r, --read-only Execute the grpck command in read-only mode. This causes all questions regarding changes to be answered no without user intervention. -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. -s, --sort Sort entries in /etc/group and /etc/gshadow by GID. By default, grpck operates on /etc/group and /etc/gshadow. The user may select alternate files with the group and shadow parameters. CONFIGURATION
The following configuration variables in /etc/login.defs change the behavior of this tool: MAX_MEMBERS_PER_GROUP (number) Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID). The default value is 0, meaning that there are no limits in the number of members in a group. This feature (split group) permits to limit the length of lines in the group file. This is useful to make sure that lines for NIS groups are not larger than 1024 characters. If you need to enforce such limit, you can use 25. Note: split groups may not be supported by all tools (even in the Shadow toolsuite). You should not use this variable unless you really need it. FILES
/etc/group Group account information. /etc/gshadow Secure group account information. /etc/passwd User account information. EXIT VALUES
The grpck command exits with the following values: 0 success 1 invalid command syntax 2 one or more bad group entries 3 can't open group files 4 can't lock group files 5 can't update group files SEE ALSO
group(5), groupmod(8), gshadow(5), passwd(5), pwck(8), shadow(5). shadow-utils 4.1.5.1 05/25/2012 GRPCK(8)
All times are GMT -4. The time now is 03:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy