I have strigns below, in which we have files names. Can we parse them in one algorithm? If not, the


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I have strigns below, in which we have files names. Can we parse them in one algorithm? If not, the
# 1  
Old 03-02-2017
I have strigns below, in which we have files names. Can we parse them in one algorithm? If not, the

I have several strings with files names
roundrobin_report_report_ALL_dbagadm_${Today}-${TM}_U.csv

I want to say That I found a way to have prefix roundrobin_report_report_ALL_dbagadmU.
Code:
letter=`echo $var |  cut -d'.' -f 1 |  rev | cut -d'_' -f 1 | rev`
echo "NAME = $letter"
prefix=`echo $var |  cut -d'_' -f-5`
echo "PREF $prefix"
prefixname=$prefix$letter

Now could you help me top get ${Today}-${TM} from this string?

Last edited by vgersh99; 03-02-2017 at 06:26 PM.. Reason: code tags, please!
# 2  
Old 03-02-2017
Code:
echo 'roundrobin_report_report_ALL_dbagadm_${Today}-${TM}_U.csv' | awk -F'$' '{print substr($0,1, index($0,"$")-2)}'
echo 'roundrobin_report_report_ALL_dbagadm_${Today}-${TM}_U.csv' | sed 's/_\$.*//'

Code:
echo 'roundrobin_report_report_ALL_dbagadm_${Today}-${TM}_U.csv' | awk -F_ '{print $(NF-1)}'
echo 'roundrobin_report_report_ALL_dbagadm_${Today}-${TM}_U.csv' | sed 's/.*_\(\$[^_][^_]*\).*/\1/'


Last edited by vgersh99; 03-02-2017 at 06:44 PM..
This User Gave Thanks to vgersh99 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exclude certain file names while selectingData files coming in different names in a file name called

Data files coming in different names in a file name called process.txt. 1. shipments_yyyymmdd.gz 2 Order_yyyymmdd.gz 3. Invoice_yyyymmdd.gz 4. globalorder_yyyymmdd.gz The process needs to discard all the below files and only process two of the 4 file names available ... (1 Reply)
Discussion started by: dsravanam
1 Replies

2. Shell Programming and Scripting

Parse csv files by their names

HI all I have multiple csv files with the names VAR1_VAR2_VAR3_VAR4.csv All the files have the same structure inside just values change. I am trying to retrieve data from those files by fixing at each time one or more VAR. I tried to write a script but I have 2 problems: 2-... (1 Reply)
Discussion started by: Jhon.c
1 Replies

3. Shell Programming and Scripting

Algorithm to load files efficiently without missing or accidently archiving....

We have a requirement where we get the Delta Files in every one hour and we need to load them into Oracle database every one hour using Powercenter. To efficiently do this we need to build an File management system. Here is our process: we get 6 files for 6 tables with a timestamp appended... (2 Replies)
Discussion started by: okkadu
2 Replies

4. Shell Programming and Scripting

Parse 2 or more files into one.

Hi, I have a really simple question...I think. I want to be able to parse two or more files into one by reading the first record from each file into new file then go back to the first file and start reading the second record in from each file into new file and so on. I am new to using awk and am... (5 Replies)
Discussion started by: qray2011
5 Replies

5. Shell Programming and Scripting

parse file names

trying to parse out all parts of this file name. REC=`echo "CAMXI.F0150.txt" | sed 's/.*\(*\).*/\1/'` export "FLRECL=$REC" FLECL=0150 I can get the numbers 0150 out of the file name. But need to capture first 5 bytes and extension. So i would export 3 variables (name, length, extension)... (5 Replies)
Discussion started by: rapalanlord
5 Replies

6. Shell Programming and Scripting

how to copy files followed by list of names of all the files in /etc?

....... (2 Replies)
Discussion started by: pcbuilder
2 Replies

7. Shell Programming and Scripting

algorithm for comparing files

hi i have 1000 files, i need to compare files with one another, can some help with logic with to decrease the no of comparings thanks Satya (1 Reply)
Discussion started by: Satyak
1 Replies

8. Shell Programming and Scripting

parse files and delete

For the CSV file it should have one entry per line looking like this: pwd/filename,YYYYMMDDhhmmss,OK The date stamp should be from the file properties and OK will be a constant. find . name 'W*' gives me the proper list of files and date +%Y%m%d%H%M%S is the proper date format but I... (0 Replies)
Discussion started by: pimentelgg
0 Replies

9. Shell Programming and Scripting

How to parse 2 files simultaneously

Say I have 2 files of 2 rows of 3 columns each file1: cat catdata1 catdata2 dog dogdata1 dogdata2 file2: cat catdata3 catdata4 dog dogdata3 dogdata4 and I need to combine both files so that is appears like: cat catdata1 catdata2 catdata3 catdata4 dog dogdata1 dogdata2 dogdata3... (8 Replies)
Discussion started by: Awanka
8 Replies
Login or Register to Ask a Question