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
vxddladm(1M)															      vxddladm(1M)

NAME
vxddladm - Device Discovery Layer subsystem administration SYNOPSIS
/etc/vx/bin/vxddladm keyword [attribute[=value] ...] vxddladm [-a | -f | -n] addforeign {dir=pathname | path=pathname} vxddladm [-a | -f | -n] addforeign {dirname=pathname | pathname=pathname} vxddladm [-a | -f | -n] addforeign blockdir=pathname chardir=pathname vxddladm [-a | -f | -n] addforeign blockpath=pathname charpath=pathname vxddladm addjbod vid=vendor-id [pid=product-id] [opcode=scsi_opcode] [pagecode=page_code] [offset=page_offset] [length=sno_length] [policy={aa|ap}] vxddladm disablescsi3 vxddladm enablescsi3 [policy={aa|ap}] vxddladm excludearray libname=libname vxddladm excludearray vid=vendor-id pid=product-id vxddladm excludearray vid=vendor-id vxddladm excludearray pid=product-id vxddladm excludearray all vxddladm get namingscheme vxddladm gettune {all | tunable} vxddladm includearray libname=libname vxddladm includearray vid=vendor-id pid=product-id vxddladm includearray vid=vendor-id vxddladm includearray pid=product-id vxddladm includearray all vxddladm listexclude [all] vxddladm listforeign vxddladm listjbod [vid=vendor-id [pid=product-id]] vxddladm listsupport [all | libname=libname] vxddladm listversion [all | libname=libname] vxddladm modescsi3 vxddladm rmforeign {dir=pathname | path=pathname} vxddladm rmforeign {dirname=pathname | pathname=pathname} vxddladm rmforeign blockdir=pathname chardir=pathname vxddladm rmforeign blockpath=pathname charpath=pathname vxddladm rmjbod vid=vendor-id [pid=product-id] vxddladm set namingscheme={ebn|osn} [persistence={yes|no}] [mode={default|legacy|new}] vxddladm settune tunable=value vxddladm start eventsource vxddladm stop eventsource DESCRIPTION
The vxddladm utility is an administrative interface to the dynamic array support facility of the Device Discovery Layer (DDL). This util- ity lists the types of arrays supported, adds or removes array support from DDL, and allows dynamic addition of JBOD support for disks from different vendors. It additionally lists supported JBODs, and allows addition or removal of JBOD support. The vxddladm utility is also used to customize the set of array libraries that can participate in device discovery. DDL cannot discover some devices that are controlled by third-party drivers (for example, EMC PowerPath and RAM disks). Additionally, it may be preferable to use the multipathing capability that is provided by the third-party drivers for some arrays rather than use the Veri- tas Dynamic Multipathing (DMP) feature. Such foreign devices can be made available as simple disks to VxVM by using the vxddladm addfor- eign command. This command also has the effect of bypassing DMP for the specified devices. If a foreign device has alias devices in the OS-maintained device tree, DDL/DMP creates additional disk access records that point to the same physical device. As such additional records are usually not required, you can specify the -a option to prevent them from being cre- ated. After adding or removing foreign device entries, use either the vxdisk scandisks command or the vxdctl enable command to discover the for- eign devices as simple disks. These disks then behave in the same way as autoconfigured disks. KEYWORDS
addforeign Adds an entry to the list of foreign devices that are not autoconfigurable by VxVM. See the ATTRIBUTES section for a description of the attributes that can be used with addforeign: blockdir, blockpath, chardir, charpath, dir, dirname, path and pathname. All directory and device arguments to these attributes must be specified as absolute pathnames. Device paths may include the * wildcard. One of the following options may also be specified to define how alternate device entries that are discovered by VxVM are to be treated: -a Suppresses any entries for matching devices in the OS-maintained device tree that are found by the VxVM autodiscovery mecha- nism. This is the default action if no option is specified to addforeign. -f Retains any entries for matching devices found by the VxVM autodiscovery mechanism, and suppresses any foreign device entries that are defined. -n Does not suppress any entries. Duplicate entries for foreign devices are allowed. addjbod Adds disks having the specified VID and PID in the JBOD category (DISKS). The policy option may be specified to handle JBOD arrays in either active/active (aa) or active/passive (ap) mode. By default, JBOD disks are handled as active/active arrays. disablescsi3 Disables the discovery of SCSI3 disks in the JBOD category. enablescsi3 Initiates the method to discover SCSI3-conformant disks. Such disks, if found, are categorized in the JBOD category. The method comes into effect when the discovery operation is subsequently invoked. The policy option may be specified to discover devices in active/active (aa) or active/passive (ap) mode. By default, devices are discovered in active/active mode. excludearray Excludes the specified array libraries from participating in device discovery. This does not remove the specified libraries from the system. As a result, vxddladm listsupport displays the corresponding disk arrays. get namingscheme Returns the current setting of the disk device naming scheme. gettune Returns the value of a specified DDL tunable parameter. If all is specified, a list of all the DDL tunables and their values is displayed. includearray Includes the array libraries previously excluded by excludearray. These can be used for device discovery operations. listexclude Lists information about the disk array libraries excluded from device discovery functionality. listforeign Lists information about foreign devices that have been defined to VxVM. listjbod Lists information about the types of disks supported in JBOD category (DISKS). listsupport Lists summary information about supported disk arrays. The libname attribute can be used to display a detailed list of attributes for a specified library. listversion Lists the version numbers of array support libraries and the minimum VxVM release that is required for each library. The libname attribute can be used to request that the information is to be displayed only for the specified library. modescsi3 Displays the mode for SCSI3 disk discovery. By default, devices are discovered in active/active mode. rmforeign Removes a matching entry from the list of foreign directories and devices. See the ATTRIBUTES section for a description of the attributes that can be used with rmforeign: blockdir, blockpath, chardir, charpath, dir, dirname, path and pathname. rmjbod Removes disk with the specified VID and PID from the JBOD category (DISKS). These disks are categorized as OTHER_DISKS and are not multipathed. set namingscheme={ebn|osn} [persistence={yes|no}] Bases the name of a device on the enclosure name (ebn), or on the device name that is used by the operating system (osn). The change is immediate, and does not require vxconfigd to be restarted. The optional persistence argument allows you to select whether the names of disk devices that are displayed by VxVM remain unchanged after disk hardware has been reconfigured and the system rebooted. By default, enclosure-based naming and operating system-based naming are persistent (yes). VxVM commands display device names according the current naming scheme. If operating system-based naming is selected, all VxVM commands that list DMP node devices will display device names according to the mode that is specified: default The same format is used as in the input to the command (if this can be determined). Otherwise, legacy names are used. This is the default mode. legacy Only legacy names (in c#t#d# format) are displayed. new Only new (agile) names (in disk## format) are displayed. settune Sets the value of the specified DDL tunable parameter. This value takes precedence over any value that is set using the method provided by the operating system. The changed value is persistent across reboots of the system. The following tunable parameter may be changed for DDL: monitor_fabric Controls whether the Event Source daemon (vxesd) uses the Storage Networking Industry Association (SNIA) HBA API. This API allows DDL to improve the performance of failover by collecting information about the SAN topology and by monitor- ing fabric events. If set to on, DDL uses the SNIA HBA API. (Note that the vendor-provided ASL must also support the use of the SNIA HBA API.) If set to off, the SNIA HBA API is not used. The default setting is off for releases prior to 5.0 that have been patched to support this DDL feature. The default setting is on for 5.0 and later releases. start eventsource stop eventsource Starts or stops the event source daemon. This daemon passes disk-related events to DDL. For example, if a disk is added, removed, or changed, DDL invokes the device discovery actions that are related to that disk event. ATTRIBUTES
The attribute all selects all objects for an operation. Other attributes are specified using the format attribute=value. blockdir Absolute pathname of a directory that contains block device entries for foreign devices. blockpath Absolute pathname of the block device for a foreign device. chardir Absolute pathname of a directory that contains character device entries for foreign devices. charpath Absolute pathname of of a character device for a foreign device. dir Absolute pathname of a directory that contains character and block device entries for foreign devices. dirname Equivalent to dir. length Size of the field containing unique disk serial number. libname Name of the array library on which the operation is to be performed. offset Offset on the page code. opcode SCSI opcode. pagecode Page code for SCSI command. path Absolute pathname of a single character or block device for a foreign device. pathname Equivalent to path. pid Product ID of the disk array. policy Sets the policy of the specified device to aa (active/active) or ap (active/passive). vid Vendor ID of the disk array. NOTES
If you specify values for vid or pid to the excludearray or includearray operations, this excludes or includes all arrays that are sup- ported by the corresponding array library. The value for vid and pid should be taken from the output of the vxddladm listsupport command. These values may be different from the actual vid and pid values of the disks within an array. See the vxdiskadm(1M) manual page for information on using the vxdiskadm command to suppress or unsuppress individual devices from the view of VxVM, or to disable or enable multipathing for these devices. FILES
/etc/vx/darecs Used to store records for foreign devices. SEE ALSO
vxconfigd(1M), vxdctl(1M), vxdisk(1M), vxdiskadm(1M), vxdmpadm(1M) VxVM 5.0.31.1 24 Mar 2008 vxddladm(1M)
All times are GMT -4. The time now is 01:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy