Sponsored Content
Top Forums Shell Programming and Scripting Help on substring of file list Post 302303544 by vino on Friday 3rd of April 2009 01:03:25 AM
Old 04-03-2009
Quote:
Originally Posted by victorcheung
Hi,

I have a folder list as below, I want to write a script to return a list like:
CASTLE_BU_20080801
CAUSEWAY_BU_20080801
HUNGHOM_BU_20080801
:
:

Can anyone help?

Thanks!
Victor Cheung

List of the folder:
Code:
# ls
CASTLE_BU_20080801.DMP      OFFICE_MY1_BU_20080801.DMP
CAUSEWAY_BU_20080801.DMP    OFFICE_MY2_BU_20080801.DMP
HUNGHOM_BU_20080801.DMP     OFFICE_SC_BU_20080801.DMP
KLN_CITY_BU_20080801.DMP    OFFICE_SW_BU_20080801.DMP
KWUNTONG_BU_20080801.DMP    PRINCE_BU_20080801.DMP
MEIFOO_BU_20080801.DMP      SHANGHAI_BU_20080801.DMP
MONGKOK_BU_20080801.DMP     SHANTUNG_BU_20080801.DMP
NORTH_PT_BU_20080801.DMP    SHAUKW_BU_20080801.DMP
OFFICE_HT_BU_20080801.DMP   TAIWAI_BU_20080801.DMP
OFFICE_IC_BU_20080801.DMP   TSUENWAN_BU_20080801.DMP
OFFICE_LN_BU_20080801.DMP   TUENMUN_BU_20080801.DMP
OFFICE_MC_BU_20080801.DMP   WANCHAI_BU_20080801.DMP
OFFICE_MS_BU_20080801.DMP   YUENLONG_BU_20080801.DMP
OFFICE_MW_BU_20080801.DMP
#

Do you want to strip off the .DMP extension ?
Code:
for file in *.DMP
do
  echo ${file%%\.DMP}
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling a substring from another file

I have two files: One is a list of numbers: 1 5 6 7 10 The second is a very long string abcdefghijklmno......1234567890 I'd like to print a new file with a 5 character substring that starts at each the positions listed in the 1st file: such as: abcde (4 Replies)
Discussion started by: dcfargo
4 Replies

2. Shell Programming and Scripting

substring from list of files?

Hi All, In my unix folder there are 2 types of files available. Indicator file & data file. ABC2008110601.TXT ABC2008110901.TXT ABC2008111001.TXT ABC2008111101.TXT ABCIND2008110601.TXT ABCIND2008110901.TXT ABCIND2008111001.TXT ABCIND2008111101.TXT what i want is that first i need to get... (3 Replies)
Discussion started by: Amit.Sagpariya
3 Replies

3. Shell Programming and Scripting

extracting substring from a file name

hi i need to name a file with a substring of a another file name. i.e. if the old filename is abc.txt , the new filename should be abc_1.txt i should get the substring of the file name and then name the new one please let me know how to do it (4 Replies)
Discussion started by: adityamahi
4 Replies

4. Shell Programming and Scripting

How do I pull a substring out of a file?

I'm new to shell scripting and am trying to write a small script that pulls a substring out of a file that has a few lines of text in it. The file will eventually have a lot of text, I just put a few lines in it for testing purposes. Anyway, this is what I have so far... #!/bin/ksh ... (4 Replies)
Discussion started by: enator45
4 Replies

5. Shell Programming and Scripting

Get value of substring from a file

Hi, I have a file with a long string, in the format: name1=value,name2=value2.....namen=valuen I want to query the file and extract 'value2' ONLY. name2=value2 can exist anywhere within the file. Can anyone help me please wth a suitable BASH command? Many thanks, Matt (4 Replies)
Discussion started by: mjwoodford
4 Replies

6. Shell Programming and Scripting

Substring from the file name

Hi I need substring from the file name of list of files. I mean i will have to load all the files into database which are there in the Directory. I need to make the directory with the date(which is substring of the filename Eg: Filename_Name_2012013001010101.txt, So the directory should be... (11 Replies)
Discussion started by: cnrj
11 Replies

7. Shell Programming and Scripting

Get Substring from file name.

Hi, In my shell script. I am reading all files in directory. And say if the file names are as follows: adio_idfl_201302_df.txt dfa_201301_dll.ctl dalkd_20130301.csv I would like to extract the numeric piece of each file name and display as follows: 201302 201301 20130301 I... (9 Replies)
Discussion started by: pinnacle
9 Replies

8. UNIX for Dummies Questions & Answers

Deleting file basing on the timestamp substring in the file name

Hello, I have in my backup folder, files with names convention like this : randomFileNames_13-02-2014_23h13m09+1392333189 randomFileNames_14-02-2014_02h13m09+1392343989 randomFileNames_14-02-2014_04h13m09+1392351189 etc.... Base on timestamp at end of the filename, I would to delete all the... (7 Replies)
Discussion started by: thuyetti
7 Replies

9. Shell Programming and Scripting

Extract substring in a file

Hello, A question please. A have a file that contains a string. Ex: AAAABBCCCCCDDEEEEEEEEEEFF I'd want to recover 2 substrings, 'BB' and 'FF' and then leave them in a new file. Could anoyone help me please? Thanks in advance (3 Replies)
Discussion started by: nolo41
3 Replies

10. Shell Programming and Scripting

Extract a substring from a file

Hello, A question please. A have a file that contains a string. Ex: AAAABBCCCCCDDEEEEEEEEEEFF I'd want to recover 2 substrings, 'BB' and 'FF' and then leave them in a new file. From position 5, 2 caracters (ex:"BB") and from position 25, 2 caracters (ex:"FF") in a file. Could anoyone help me... (3 Replies)
Discussion started by: nolo41
3 Replies
RMF(1)								     [nmh-1.5]								    RMF(1)

NAME
rmf - remove an nmh folder SYNOPSIS
rmf [+folder] [-interactive | -nointeractive] [-version] [-help] DESCRIPTION
Rmf removes all of the messages (files) within the specified (or default) folder, and then removes the folder (directory) itself. If there are any files within the folder which are not a part of nmh, they will not be removed, and an error will be produced. If the folder is given explicitly or the -nointeractive option is given, then the folder will be removed without confirmation. Otherwise, the user will be asked for confirmation. If rmf can't find the current folder, for some reason, the folder to be removed defaults to `+inbox' (unless overridden by user's profile entry "Inbox") with confirmation. If the folder being removed is a subfolder, the parent folder will become the new current folder, and rmf will produce a message telling the user this has happened. This provides an easy mechanism for selecting a set of messages, operating on the list, then removing the list and returning to the current folder from which the list was extracted. If rmf s used on a read-only folder, it will delete all the (private) sequences (i.e., "atr-seq-folder" entries) for this folder from your context without affecting the folder itself. Rmf irreversibly deletes messages that don't have other links, so use it with caution. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder Inbox: To find the default inbox SEE ALSO
rmm(1) DEFAULTS
`+folder' defaults to the current folder, usually with confirmation `-interactive' if +folder' not given, `-nointeractive' otherwise CONTEXT
Rmf will set the current folder to the parent folder if a subfolder is removed; or if the current folder is removed, it will make "inbox" current. Otherwise, it doesn't change the current folder or message. BUGS
Although intuitively one would suspect that rmf works recursively, it does not. Hence if you have a sub-folder within a folder, in order to rmf the parent, you must first rmf each of the children. MH.6.8 11 June 2012 RMF(1)
All times are GMT -4. The time now is 11:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy