#!/bin/sh
for i in "/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_"$(date +%Y-%m-%d --date "4 day ago")"_tmptcmsaslva2_"*".log"
do
echo "${/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/##*/}"
done < output_file.txt
Got error as
Code:
line 4: ${/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/##*/}: bad substitution
My requirement was to have only the file name (instead of filename with directories) in output_file.txt
---------- Post updated at 07:20 AM ---------- Previous update was at 07:16 AM ----------
My script location and output file location is /usr/sas/tir/test/loganalysis.
I need to search for a file in /usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/.
Now how to modify your script to include the directories?
#!/bin/sh
for i in "/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_"$(date +%Y-%m-%d --date "4 day ago")"_tmptcmsaslva2_"*".log"
do
echo "${/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/##*/}"
done < output_file.txt
Got error as
Code:
line 4: ${/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/##*/}: bad substitution
My requirement was to have only the file name (instead of filename with directories) in output_file.txt
Hello Ram,
You should put $i as follows in code.
Code:
#!/bin/sh
for i in "/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_"$(date +%Y-%m-%d --date "4 day ago")"_tmptcmsaslva2_"*".log"
do
echo "${i##*/}"
done < output_file.txt
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
It is an example of parameter expansion, you can go through following.
Quote:
${parameter#word}${parameter##word}
The word is expanded to produce a pattern just as in filename expansion (see Filename Expansion). If the pattern matches the beginning of the expanded value of parameter, then the result of the expansion is the expanded value of parameter with the shortest matching pattern (the ‘#’ case) or the longest matching pattern (the ‘##’ case) deleted. If parameter is ‘@’ or ‘*’, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with ‘@’ or ‘*’, the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list.
${parameter%word}${parameter%%word}
The word is expanded to produce a pattern just as in filename expansion. If the pattern matches a trailing portion of the expanded value of parameter, then the result of the expansion is the value of parameter with the shortest matching pattern (the ‘%’ case) or the longest matching pattern (the ‘%%’ case) deleted. If parameter is ‘@’ or ‘*’, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with ‘@’ or ‘*’, the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list.
HI Guys,
I have Input:- A
nput A.txt
000100/port_xcu_dev_6/port_0_dev_7
000100/port_xcu_dev_6/port_1_dev_10
000100/port_xcu_dev_2/port_2_dev_8
000100/port_xcu_dev_3/port_3_dev_11
000100/port_xcuv_9/port_4_dev_9 ... (3 Replies)
Hi,
I have to search a word in a text file and then I have to delete lines above from the word searched . For eg suppose the file is like this:
Records
P1
10,23423432
,77:1
,234:2
P2
10,9089004
,77:1
,234:2
,87:123
,9898:2
P3
456456
P1
:123,456456546
P2
abc:324234 (2 Replies)
Hi,
I am new to unix. I want to delete 2 words placed at position say for example at 23rd and 45th position in a line. I used sed but couldnt achieve this.
Example: the file contains 2 lines
12345 98765 "12345" 876
12345 98765 "64578" 876
I want to delete " placed at position 13 and 19... (4 Replies)
Hi All,
I have a file with the data as below. In this i want to delete the last word. Could you pls help me.
$INSTALL_HOME/lib/fm_voucher_pol.so
$INSTALL_HOME/source/sys/fm_apn_pol/fm_apn_pol_device_set_state.c
In the above two lines i want to delete fm_voucher_pol.so and... (5 Replies)
I'm looking for a command that will read a file listing information and delete everything after a certain word is found. I also may need to search the file and delete everything before a certain word. The file would contains fields of information like below repeating for the entire file;
Name... (5 Replies)
Friends, I'm looking for a command that delete the first tho caractere in a word. Here is an exp :
I want to replace "20091001" by "091001"
or "replace" by "place"
Thx, (13 Replies)
Hi,
I need to find a word in a file, and I need to delete the file where the word resides on the file.
I did try with the grep -H "word" using the find command, but no luck. (6 Replies)
Hi expert,
I am using C shell. And i trying to delete repeated word.
Example file.txt:
BLUE
YELLOW
RED
VIOLET
RED
RED
BLUE
WHITE
YELLOW
BLACK
and i wan store the output into a new file:
BLUE (6 Replies)
i have created the following input script
CREATE OR REPLACE VIEW MMSSENDAVGUPLOADTIME_GN
AS
sp_strip_mean_value_type.get_val(MMSSENDAVGUPLOADTIME) MMSSENDAVGUPLOADTIME_val
sp_strip_mean_value_type.get_val(MMSSENDAVGUPLOADTIME) MMSSENDAVGUPLOADTIME_counter
select... (1 Reply)
Hi All,
I want to delete a word from file. How to do that.
I have file that contains the following Information.
EntityName:alba00r1.mis.amat.com OverallStatus:Minor IfName:Gi1/0
EntityName:alba00r1.mis.amat.com ] OverallStatus:Normal IfName:Se0/0/0... (4 Replies)