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

NAME
vxdctl - control the volume configuration daemon SYNOPSIS
vxdctl cacheenable vxdctl debug level [pathname] vxdctl cacheenable vxdctl cachedisable vxdctl cacheflush vxdctl defaultdg diskgroup vxdctl disable vxdctl [-f] enable vxdctl hostid hostid vxdctl init [hostid] vxdctl initdmp vxdctl license [init] vxdctl list vxdctl [-c] mode vxdctl protocolrange vxdctl protocolversion vxdctl [-f] set attribute[=value] vxdctl [-k] stop vxdctl support vxdctl [-F] unset attribute vxdctl upgrade DESCRIPTION
The vxdctl utility manages aspects of the state of the volume configuration daemon, vxconfigd, sets the default disk group for the system, and also sets up the boot disk group if the root disk is under Veritas Volume Manager (VxVM) control. The volboot file forms a key element in managing the state of vxconfigd and importing the boot disk group. This file contains a host ID that VxVM uses to establish ownership of physical disks. The host ID is used to ensure that two or more hosts do not interfere with each other when accessing disks on a shared SCSI bus or Storage Area Network (SAN). VxVM also uses host IDs to generate unique ID strings for stamping disks and disk groups. Note: The purpose of the cluster environment is to allow hosts that can access disks on a shared bus to do so in a coordinated way. In this environment, the host ID is not used to prevent shared access; however, it is used for other internal functions. The volboot file contains the name of the system-wide default disk group if this has been configured. If the root disk is under VxVM con- trol, the volboot file also contains the name of disk group, the boot disk group, to which the root disk belongs. vxconfigd operates in one of the following modes: enabled, disabled or booted. The enabled state is the normal operating state. Most configuration operations are allowed in this state. Entering the enabled state imports all disk groups, and begins the management of device nodes stored in the /dev/vx/dsk and /dev/vx/rdsk directories. In the disabled state, vxconfigd does not retain configuration information for the imported disk groups, and does not maintain the volume device directories. Most operations are disallowed in this state. Certain failures, such as the volboot file not being loaded or devices not being auto-configured, cause vxconfigd to enter the disabled state automatically. The booted state is entered as part of normal system startup, prior to checking the root file system with fsck. If the root disk is under VxVM control, entering the booted mode imports the boot disk group. If the root disk is not under VxVM control, no disk groups are imported. vxconfigd then waits for a request to enter the enabled mode. The volume device node directories are not maintained in booted mode, because it may not be possible to write to the root file system. The action performed by vxdctl depends upon the specified keyword operand(s). KEYWORDS
cacheenable Requests that caching of device opens are enabled in the VxVM kernel module. At the VxVM configuration discovery time a disk device may be opened and closed multiple times. Depending on the disk array(s) being used, multiple opens of the same device could delay the startup time of the vxconfigd significantly. To minimize the delay in multiple opens, the first open of the device is cached and used for subsequent opens. When the machine is booting, the caching is automatically enabled to speed up the boot process. Once the machine has been booted, the caching is disabled via the VxVM startup script. cachedisable Request that caching of device opens are disabled and the currently cached devices are flushed from the VxVM kernel module. cacheflush Request that any cached device open entries in the VxVM kernel module are flushed. debug Sets the vxconfigd debugging level from 0 to 9. If set to 0, debug output is disabled. If a pathname is specified, debug output is directed to this file. defaultdg Specifies the system-wide default disk group that is aliased by the reserved name, defaultdg. You can use the command vxdg defaultdg to display the currently defined default disk group. If bootdg is specified as the argument to this command, the default disk group is set to be the same as the currently defined system-wide boot disk group. You can use the command vxdg bootdg to display the currently defined boot disk group. If nodg is specified as the argument, the default disk group is undefined. Note: The specified disk group need not currently exist on the system. disable Requests that vxconfigd enter disabled mode. This may be necessary to perform some maintenance operations. This does not dis- able any configuration state loaded into the kernel. It only prevents further configuration changes to loaded disk groups until vxconfigd is re-enabled. enable Requests that vxconfigd enter enabled mode, import all disk groups, and rebuild the volume device node directories. This opera- tion can be used even if vxconfigd is already in enabled mode. The primary purpose for using this operation when in enabled mode is to rebuild the volume device nodes. This operation causes vxconfigd to scan for any disks that were newly added since vxcon- figd was last started. In this manner, disks can be dynamically configured to the system and then recognized by VxVM. If the multipathing support is available, this option also causes vxconfigd to rebuild the DMP internal database to reflect the new state of the system after addition of the disk devices. The new disk devices detected by vxconfigd are added in the DMP database with their associated subpaths and parent DMP device. By default, VxVM performs a full scan of the device tree when performing device discovery. To discover only newly added disks that are not already known to VxVM, specify the -f option. hostid Changes the host ID in the volboot file, and on all disks in disk groups currently imported on this machine. It may be desirable to change the VxVM host ID for your machine if you change the network node name of your machine. If some disks are inaccessible at the time of a hostid operation, it may be necessary to use the vxdisk clearimport operation to clear out the old host ID on those disks when they become reaccessible. Otherwise, you may not be able to re-add those disks to their disk groups. Note: Be careful when using this command. If the system crashes before the hostid operation completes, some disk groups may not reimport automatically. init Reinitializes the volboot file with a new host ID, highest supported cluster protocol version, system-wide default disk group name, and boot disk group name (if the root disk is under VxVM control). If a hostid operand is specified, this string is used; otherwise, a default host ID is used. The default host ID is normally taken as the network node name for the host (see uname(1M)). On systems with a hardware-defined system ID, the default host ID might be derived from this hardware ID. initdmp Creates user-level DMP metanodes for all DMP devices that the kernel has detected. If a DMP metanode is missing, a new node is created. If a DMP metanode already exists, the node is not touched. license [init] Without any arguments, the vxdctl license command prints the list of features which are currently available based on known licensing information. Note: If only a Base VxVM license is installed, the vxdctl license command displays "DMP (single path enabled)". If either the Full VxVM license or an automatically generated license (such as that for the PHOTON array) is installed, the command displays "DMP (multipath enabled)". With the init argument specified, the vxdctl license init command requests that vxconfigd re-read any persistently stored license information. If licenses have expired, this can make some features unavailable. If new licenses were added, but are not yet recognized by vxconfigd, this command forces vxconfigd to rescan the licenses, and to make the new licenses available. list Lists the contents of the volboot file including the host ID, some sequence numbers, the cluster protocol version, the name of the system-wide default disk group (if any), the name of the boot disk group (if the root disk is under VxVM control), and the site name (if defined). mode Prints the current operating mode of vxconfigd. The output format is: mode: operating_mode where operating_mode is one of enabled, disabled, booted, or not-running. If the -c flag is specified and vxconfigd is in the enabled mode, the clustered state of vxconfigd is displayed. The output for- mat is: mode: enabled: clustered_state where clustered_state is one of cluster inactive, cluster active - role not set, cluster active - MASTER, cluster active - SLAVE. This information is only available if the VxVM cluster feature is enabled. protocolrange Print the cluster protocol range supported by the node. The output format is: minprotoversion: minimum protocol version, maxprotoversion: maximum protocol version protocolversion Prints the current cluster protocol version of the node. The output format is: cluster running at protocol protocolversion The protocolversion is a value in the range listed by vxdctl protocolrange. This information is only available if the VxVM clus- ter feature is enabled. set attribute[=value] Defines an attribute and associated value. Currently, the only supported attribute is site, which is used to define the name of the site where the system is located. This site name is stored in the volboot file, and is used to implement Remote Mirror solu- tions and the site_read_local preferred plex read policy of the vxvol command. If a site name is already defined for any imported disk groups, the operation fails unless the -f option is specified. support Displays information about the versions of VxVM objects and components that are supported by the configuration daemon that is currently running. Versions are printed as colon-separated name/value pairs: vxconfigd_vrsn Version of vxconfigd that is currently running. dg_minimum Lowest disk group version supported by vxconfigd. dg_maximum Highest disk group version supported by vxconfigd. kernel Highest kernel version supported by vxconfigd. protocol_minimum Lowest cluster protocol version supported by the node. protocol_maximum Highest cluster protocol version supported by the node. protocol_current Cluster protocol version currently running on the node. The protocol version information is only meaningful for the VxVM cluster feature. stop Requests that vxconfigd exit. This may be necessary to reset VxVM, such as when the -r reset option is specified to vxconfigd. This command does not disable any configuration state that is loaded into the kernel. It only affects the ability to make con- figuration changes until vxconfigd is restarted. If the -k option is used, vxconfigd is stopped by sending it a SIGKILL signal. The command pauses for up to one second to verify that vxconfigd has exited. It returns an error if vxconfigd has not exited after one second's delay has elapsed. unset Removes an attribute from the volboot file. Currently, the only supported attribute is site, which is used to define the name of the site where the system is located. If the site name is already defined for any imported disk groups, the operation fails unless the -F option is specified. upgrade Requests that the cluster be upgraded to the highest cluster protocol possible. This is only available if the VxVM cluster fea- ture is enabled. FILES
/etc/vx/volboot File containing miscellaneous boot information. /etc/vx/darecs File containing a list of disks to be scanned and configured. NOTES
From release 4.0 of VxVM, the add disk and rm disk commands are no longer supported. SEE ALSO
fsck(1M), signal(5), uname(1M), vxconfigd(1M), vxdg(1M), vxdisk(1M), vxdmp(7), vxintro(1M), vxlicinst(1), vxlicrep(1) VxVM 5.0.31.1 24 Mar 2008 vxdctl(1M)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy