How to use ls with pattern and including path?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use ls with pattern and including path?
# 22  
Old 08-21-2014
Quote:
Originally Posted by Corona688
Then why wouldn't KSH see them?
Hi Corona,
I must have missed something. I haven't seen anything showing that Ophiuchus tried using ksh instead of bash and got different results. I thought Ophiuchus was seeing unexpected files on a Linux system, and didn't see those results on a Cygwin system (presumably also using bash), but presumably looking at files in a different directory.

Hi Ophiuchus,
On your Linux system, please start a Korn shell (ksh) and then while in that shell rerun the commands:
Code:
ls -lst abc*.txt
printf "%s\n" *00z* *113*abc*.txt abc*113*.txt|od -cb

If we get different output from these commands using bash and ksh when in the same directory, we'll know that it is a bash option that is causing the anomalous results.
# 23  
Old 08-21-2014
Hello Don,

This is the output.
Code:
% printf "%s\n" *00z* *113*a bc*.txt abc*113*.txt|od -cb
0000000   *   0   0   z   *  \n   *   1   1   3   *   a   b   c   *   .
        052 060 060 172 052 012 052 061 061 063 052 141 142 143 052 056
0000020   t   x   t  \n   a   b   c   *   1   1   3   *   .   t   x   t
        164 170 164 012 141 142 143 052 061 061 063 052 056 164 170 164
0000040  \n
        012
0000041

# 24  
Old 08-21-2014
That's not helpful if you don't run it from the same directory as the files those expressions are supposed to match.
# 25  
Old 08-21-2014
Hello Don,

Yes, in post 17 I mentioned that when I try with ksh the output is correct. The issue is when I try with bash.
In prints below you can see that in bash, the first 5 files that appear don't begin with abc.

PS: I'm trying in the same directory with both shells.
Code:
ls -lst abc*.txt
printf "%s\n" *00z* *113*abc*.txt abc*113*.txt|od -cb
bbt@ax-1:/voddf/bbts/ax-abc/files>% echo $SHELL
/bin/bash
bbt@ax-1:/voddf/bbts/ax-abc/files>% ls -lst abc*.txt
 3080 -rw-r--r-- 1 bbt voddf 1314 Aug 21 12:12 00zabc-fgkp_1.txt
 8676 -rw-r--r-- 1 bbt voddf 1886 Aug 21 12:11 0zabc-hjki_1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 09:13 zabc-fgkp_1_1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 06:26 0zabc-hjki_1_1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 19:40 00zabc-hjki_1_2.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 17:22 abc-fgkp_1_2.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 13:34 abc-hjki_1_3.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 08:29 abc-fgkp_1_3.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 07:10 abc-hjki_1_4.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 19:27 abc-hjki_1_5.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 17:00 abc-fgkp_1_4.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 13:06 abc-hjki_1_6.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 07:36 abc-fgkp_1_5.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 06:29 abc-hjki_1_7.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 18:33 abc-hjki_1_8.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 15:36 abc-fgkp_1_6.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 11:53 abc-hjki_1_9.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 05:31 abc-fgkp_1_7.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 04:53 abc-hjki_1_10.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 18:32 abc-hjki_1_11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 15:13 abc-fgkp_1_8.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 12:54 abc-hjki_1_12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 06:15 abc-hjki_1_13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 04:42 abc-fgkp_1_9.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 19:41 abc-hjki_1_14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 14:50 abc-fgkp_1_10.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 13:26 abc-hjki_1_15.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 05:47 abc-fgkp_1_11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 16:01 abc-fgkp_1_12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 07:34 abc-fgkp_1_13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 16:36 abc-fgkp_1_14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 07:02 abc-fgkp_1_15.txt
bbt@ax-1:/voddf/bbts/ax-abc/files>% printf "%s\n" *00z* *113*a bc*.txt abc*113*.txt|od -cb
0000000   *   0   0   z   *  \n   *   1   1   3   *   a   b   c   *   .
        052 060 060 172 052 012 052 061 061 063 052 141 142 143 052 056
0000020   t   x   t  \n   a   b   c   *   1   1   3   *   .   t   x   t
        164 170 164 012 141 142 143 052 061 061 063 052 056 164 170 164
0000040  \n
        012
0000041
bbt@ax-1:/voddf/bbts/ax-abc/files>% ksh
u@h:w>% ls -lst abc*.txt
 8684 -rw-r--r-- 1 bbt voddf  887 Aug 21 12:12 abc-hjki_1.txt
 3092 -rw-r--r-- 1 bbt voddf  315 Aug 21 12:12 abc-fgkp_1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 09:13 abc-fgkp_1_1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 06:26 abc-hjki_1_1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 19:40 abc-hjki_1_2.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 17:22 abc-fgkp_1_2.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 13:34 abc-hjki_1_3.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 08:29 abc-fgkp_1_3.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 07:10 abc-hjki_1_4.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 19:27 abc-hjki_1_5.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 17:00 abc-fgkp_1_4.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 13:06 abc-hjki_1_6.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 07:36 abc-fgkp_1_5.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 06:29 abc-hjki_1_7.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 18:33 abc-hjki_1_8.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 15:36 abc-fgkp_1_6.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 11:53 abc-hjki_1_9.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 05:31 abc-fgkp_1_7.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 04:53 abc-hjki_1_10.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 18:32 abc-hjki_1_11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 15:13 abc-fgkp_1_8.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 12:54 abc-hjki_1_12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 06:15 abc-hjki_1_13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 04:42 abc-fgkp_1_9.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 19:41 abc-hjki_1_14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 14:50 abc-fgkp_1_10.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 13:26 abc-hjki_1_15.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 05:47 abc-fgkp_1_11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 16:01 abc-fgkp_1_12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 07:34 abc-fgkp_1_13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 16:36 abc-fgkp_1_14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 07:02 abc-fgkp_1_15.txt
u@h:w>% printf "%s\n" *00z* *113*abc*.txt abc*113*.txt|od -cb
0000000   *   0   0   z   *  \n   *   1   1   3   *   a   b   c   *   .
        052 060 060 172 052 012 052 061 061 063 052 141 142 143 052 056
0000020   t   x   t  \n   a   b   c   *   1   1   3   *   .   t   x   t
        164 170 164 012 141 142 143 052 061 061 063 052 056 164 170 164
0000040  \n
        012
0000041

Thanks for all help.

Best regards
# 26  
Old 08-21-2014
I apologize for missing the note about ksh working and bash failing. I obviously need more sleep.

Note that if we compare the ls output from bash and ksh, we can see that bash didn't find more files; ls mangled the names of some of the files as it was printing them when invoked from bash. Is ls a bash built-in on your system?

Code:
diff bash_ls_out ksh_ls_out
1,5c1,5
<  3080 -rw-r--r-- 1 bbt voddf 1314 Aug 21 12:12 00zabc-fgkp_1.txt
<  8676 -rw-r--r-- 1 bbt voddf 1886 Aug 21 12:11 0zabc-hjki_1.txt
< 10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 09:13 zabc-fgkp_1_1.txt
< 10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 06:26 0zabc-hjki_1_1.txt
< 10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 19:40 00zabc-hjki_1_2.txt
---
>  8684 -rw-r--r-- 1 bbt voddf  887 Aug 21 12:12 abc-hjki_1.txt
>  3092 -rw-r--r-- 1 bbt voddf  315 Aug 21 12:12 abc-fgkp_1.txt
> 10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 09:13 abc-fgkp_1_1.txt
> 10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 06:26 abc-hjki_1_1.txt
> 10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 19:40 abc-hjki_1_2.txt

Unless the files shown in red were being written between the invocations of ls, the ls invoked from bash not only mangled the names, it also mangled the i-node numbers, sizes, and timestamps.

Are we having fun yet???
# 27  
Old 08-21-2014
I suspect there are non-printing characters in these file names.

Code:
ls -lb abc*

# 28  
Old 08-21-2014
Hello guys,
I think I'll need to switch to ksh to avoid issues. I don't know if it is a built-in bash.
I've sent the ls command 3 times with a separation of 3 seconds and the output is different between them, but again, doing the same with ksh
the output is always correct.
Many thanks for all your help.
Best regards
Code:
bbt@ax-1:/voddf/bbts/ax-abc/files>% echo $SHELL
/bin/bash
bbt@ax-1:/voddf/bbts/ax-abc/files>% ls -lst abc-*.txt
 6796 -rw-r--r-- 1 bbt voddf 6943 Aug 21 17:43 00zabc-hjki1.txt
 9008 -rw-r--r-- 1 bbt voddf 9207 Aug 21 17:43 0zabc-fgkp1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 13:17 zabc-hjki11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 09:13 0zabc-fgkp11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 06:26 00zabc-hjki12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 19:40 abc-hjki13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 17:22 abc-fgkp12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 13:34 abc-hjki14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 08:29 abc-fgkp13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 07:10 abc-hjki15.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 19:27 abc-hjki16.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 17:00 abc-fgkp14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 13:06 abc-hjki17.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 07:36 abc-fgkp15.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 06:29 abc-hjki18.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 18:33 abc-hjki19.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 15:36 abc-fgkp16.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 11:53 abc-hjki110.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 05:31 abc-fgkp17.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 04:53 abc-hjki111.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 18:32 abc-hjki112.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 15:13 abc-fgkp18.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 12:54 abc-hjki113.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 06:15 abc-hjki114.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 04:42 abc-fgkp19.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 19:41 abc-hjki115.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 14:50 abc-fgkp110.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 05:47 abc-fgkp111.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 16:01 abc-fgkp112.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 07:34 abc-fgkp113.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 16:36 abc-fgkp114.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 07:02 abc-fgkp115.txt
bbt@ax-1:/voddf/bbts/ax-abc/files>% 
bbt@ax-1:/voddf/bbts/ax-abc/files>% 
bbt@ax-1:/voddf/bbts/ax-abc/files>% ls -lst abc-*.txt
 6796 -rw-r--r-- 1 bbt voddf 6945 Aug 21 17:43 abc-hjki1.txt
 9012 -rw-r--r-- 1 bbt voddf 9209 Aug 21 17:43 abc-fgkp1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 13:17 abc-hjki11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 09:13 abc-fgkp11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 06:26 abc-hjki12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 19:40 abc-hjki13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 17:22 abc-fgkp12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 13:34 zabc-hjki14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 08:29 0zabc-fgkp13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 07:10 00zabc-hjki15.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 19:27 abc-hjki16.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 17:00 abc-fgkp14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 13:06 abc-hjki17.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 07:36 abc-fgkp15.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 06:29 abc-hjki18.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 18:33 abc-hjki19.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 15:36 abc-fgkp16.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 11:53 abc-hjki110.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 05:31 abc-fgkp17.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 04:53 abc-hjki111.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 18:32 abc-hjki112.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 15:13 abc-fgkp18.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 12:54 abc-hjki113.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 06:15 abc-hjki114.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 04:42 abc-fgkp19.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 19:41 abc-hjki115.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 14:50 abc-fgkp110.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 05:47 abc-fgkp111.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 16:01 abc-fgkp112.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 07:34 abc-fgkp113.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 16:36 abc-fgkp114.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 07:02 abc-fgkp115.txt
bbt@ax-1:/voddf/bbts/ax-abc/files>% 
bbt@ax-1:/voddf/bbts/ax-abc/files>% 
bbt@ax-1:/voddf/bbts/ax-abc/files>% ls -lst abc-*.txt
 6800 -rw-r--r-- 1 bbt voddf 6948 Aug 21 17:43 abc-hjki1.txt
 9012 -rw-r--r-- 1 bbt voddf 9211 Aug 21 17:43 abc-fgkp1.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 13:17 abc-hjki11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 09:13 abc-fgkp11.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 21 06:26 abc-hjki12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 19:40 zabc-hjki13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 17:22 0zabc-fgkp12.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 13:34 00zabc-hjki14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 08:29 abc-fgkp13.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 20 07:10 abc-hjki15.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 19:27 abc-hjki16.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 17:00 abc-fgkp14.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 13:06 abc-hjki17.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 07:36 abc-fgkp15.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 19 06:29 abc-hjki18.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 18:33 abc-hjki19.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 15:36 abc-fgkp16.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 11:53 abc-hjki110.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 05:31 abc-fgkp17.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 18 04:53 abc-hjki111.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 18:32 abc-hjki112.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 15:13 abc-fgkp18.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 12:54 abc-hjki113.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 06:15 abc-hjki114.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 17 04:42 abc-fgkp19.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 19:41 abc-hjki115.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 14:50 abc-fgkp110.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 16 05:47 abc-fgkp111.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 16:01 abc-fgkp112.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 15 07:34 abc-fgkp113.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 16:36 abc-fgkp114.txt
10260 -rw-r--r-- 1 bbt voddf 1048 Aug 14 07:02 abc-fgkp115.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete a pattern including any whitespace before it and after it

Hello. A_LIGNE="cnezJ,V ,FMZ fd,Mok CODKJ,F SOME_WORD fcnQ, VMQKV Q" A_PATTERN="SOME_WORD" sed 's/'$A_PATTERN'//g' <<< "$A_LINE"will remove 'SOME_WORD' and give : "cnezJ,V ,FMZ fd,Mok CODKJ,F fcnQ, VMQKV Q"A_PATTERN="SOME_WORD]" sed 's/'$A_PATTERN'//g' <<< "$A_LINE"will remove... (4 Replies)
Discussion started by: jcdole
4 Replies

2. Shell Programming and Scripting

Comment all lines which are not already commented for each full path pattern matched

Hello. Question 1 : I want to comment out all lines of a cron file which are not already commented out for each full path pattern matched. Example 1 nothing to do because line is already commented out; pattern = '/usr/bin/munin-cron' # */5 * * * * munin test -x... (3 Replies)
Discussion started by: jcdole
3 Replies

3. Shell Programming and Scripting

Find and replace the path value in files, pattern is not full known.

Hi, I need to do find and replace, but the pattern is not full known. for example, my file has /proj/app-d1/sun or /data/site-d1/conf here app-d1 and site-d1 is not constant. It may be different in different files. common part is /proj/xx/sun and /data/xxx/conf i want to find where ever... (6 Replies)
Discussion started by: rbalaj16
6 Replies

4. Shell Programming and Scripting

Pattern match a path anywhere in the line and replace it with new path

I want to pattern match only path part from below and replace them with new path string. LoadModule jk_module /fldrA/fldrBaf/fldrCaa/modules/mod_jk.so JkWorkersFile /fldrA/fldrBaf/fldrCaa/config/OHS/ohs1/workers.properties JkLogFile... (4 Replies)
Discussion started by: kchinnam
4 Replies

5. Shell Programming and Scripting

Including EOL in egrep pattern for multiple lines

Hi all I need your help to get a high-performance solution. I am working on a extensive script to automate file restores using the bprestore tool on a Solaris 5.10 server (bash 3.00). I will only paste the needed parts of the script to avoid any confusion. To use the script the user has to... (2 Replies)
Discussion started by: Anonym
2 Replies

6. Shell Programming and Scripting

Find file and zip without including directory path

Does anyone know of a way to zip the resulting file from a find command? My approach below finds the file and zips the entire directory path, which is not what I need. After scanning the web, it seems to be much easier to perform gzip, but unfortunately the approach must use zip. find `$DIR`... (5 Replies)
Discussion started by: koeji
5 Replies

7. Shell Programming and Scripting

remove contents including the tag if pattern matches

Hi all, Can anyone help me on this. I have several WP sites that are affected by sql injections. But the contents are different as follows western union india belgaum western union india bolegaon western union india barhaj western union india budhana western union india belda western... (6 Replies)
Discussion started by: sanjuabraham
6 Replies

8. Shell Programming and Scripting

Search for Pattern and Print including Lines in between

Gurus, I have a big file that needs to be sorted out and I cant figure out what to do. The file name is as below: Name: xxxx yyyy nnnn Description: dfffgs sdgsgsf hsfhhs afgghhjdgj fjklllll gsfhfh Updated: jafgadsgg gsg Corrected: date today The file consists of line like these. ... (13 Replies)
Discussion started by: The One
13 Replies

9. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

10. Shell Programming and Scripting

Reading a path (including ref to shell variable) from file

Hi! 1. I have a parameter file containing path to log files. For this example both paths are the same, one is stated directly and the second using env variables. /oracle/admin/orcl/bdump/:atlas:trc:N ${ORACLE_BASE}/admin/${ORACLE_SID}/bdump/:${ORACLE_SID}:trc:N 2. I try to parse the path... (1 Reply)
Discussion started by: lojzev
1 Replies
Login or Register to Ask a Question