grep + FIND all files that are jar files and ended with jar [closed]

Multi tool use
With this way we can get all .jar files list:
# su -l hdfs -c " hdfs dfs -ls /home/test/jt/*.jar "
-rw-r--r-- 3 hdfs hdfs 501879 2019-03-04 10:35 /home/test/jt/cfjrfr-3.8.1.jar
-rw-r--r-- 3 hdfs hdfs 870215 2019-03-04 10:35 /home/test/jt/dhe-1.2.1.jar
-rw-r--r-- 3 hdfs hdfs 2734339 2019-03-04 10:35 /home/test/jt/34343-25.1-jre.jar
-rw-r--r-- 3 hdfs hdfs 30053 2019-03-04 10:35 /home/test/jt/23424.jar
-rw-r--r-- 3 hdfs hdfs 16481 2019-03-04 10:35 /home/test/jt/h324.jar
-rw-r--r-- 3 hdfs hdfs 29725 2019-03-04 10:35 /home/test/jt/3223kj3.jar
We try also different approach with grep, but this syntax does not return any output:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep "*.jar$"
Where I am wrong?
linux shell-script grep
closed as unclear what you're asking by G-Man, jimmij, roaima, Mr Shunz, Haxiel Mar 7 at 18:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
With this way we can get all .jar files list:
# su -l hdfs -c " hdfs dfs -ls /home/test/jt/*.jar "
-rw-r--r-- 3 hdfs hdfs 501879 2019-03-04 10:35 /home/test/jt/cfjrfr-3.8.1.jar
-rw-r--r-- 3 hdfs hdfs 870215 2019-03-04 10:35 /home/test/jt/dhe-1.2.1.jar
-rw-r--r-- 3 hdfs hdfs 2734339 2019-03-04 10:35 /home/test/jt/34343-25.1-jre.jar
-rw-r--r-- 3 hdfs hdfs 30053 2019-03-04 10:35 /home/test/jt/23424.jar
-rw-r--r-- 3 hdfs hdfs 16481 2019-03-04 10:35 /home/test/jt/h324.jar
-rw-r--r-- 3 hdfs hdfs 29725 2019-03-04 10:35 /home/test/jt/3223kj3.jar
We try also different approach with grep, but this syntax does not return any output:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep "*.jar$"
Where I am wrong?
linux shell-script grep
closed as unclear what you're asking by G-Man, jimmij, roaima, Mr Shunz, Haxiel Mar 7 at 18:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
Well, for one thing you are confusing regex and glob patterns: if you want to grep for lines ending in.jar
trygrep ".jar$"
– steeldriver
Mar 6 at 17:39
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:56
1
(a) first it's incorrect, you would need.*.jar
and (b) second it's superfluous becausegrep
outputs whole lines when a match is found (unless you are using-o
for example)
– steeldriver
Mar 6 at 18:03
2
Why are you usingsu
? What ishdfs
? Basically, why aren't you just runningls /home/test/jt/*.jar
?
– terdon♦
Mar 6 at 18:32
add a comment |
With this way we can get all .jar files list:
# su -l hdfs -c " hdfs dfs -ls /home/test/jt/*.jar "
-rw-r--r-- 3 hdfs hdfs 501879 2019-03-04 10:35 /home/test/jt/cfjrfr-3.8.1.jar
-rw-r--r-- 3 hdfs hdfs 870215 2019-03-04 10:35 /home/test/jt/dhe-1.2.1.jar
-rw-r--r-- 3 hdfs hdfs 2734339 2019-03-04 10:35 /home/test/jt/34343-25.1-jre.jar
-rw-r--r-- 3 hdfs hdfs 30053 2019-03-04 10:35 /home/test/jt/23424.jar
-rw-r--r-- 3 hdfs hdfs 16481 2019-03-04 10:35 /home/test/jt/h324.jar
-rw-r--r-- 3 hdfs hdfs 29725 2019-03-04 10:35 /home/test/jt/3223kj3.jar
We try also different approach with grep, but this syntax does not return any output:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep "*.jar$"
Where I am wrong?
linux shell-script grep
With this way we can get all .jar files list:
# su -l hdfs -c " hdfs dfs -ls /home/test/jt/*.jar "
-rw-r--r-- 3 hdfs hdfs 501879 2019-03-04 10:35 /home/test/jt/cfjrfr-3.8.1.jar
-rw-r--r-- 3 hdfs hdfs 870215 2019-03-04 10:35 /home/test/jt/dhe-1.2.1.jar
-rw-r--r-- 3 hdfs hdfs 2734339 2019-03-04 10:35 /home/test/jt/34343-25.1-jre.jar
-rw-r--r-- 3 hdfs hdfs 30053 2019-03-04 10:35 /home/test/jt/23424.jar
-rw-r--r-- 3 hdfs hdfs 16481 2019-03-04 10:35 /home/test/jt/h324.jar
-rw-r--r-- 3 hdfs hdfs 29725 2019-03-04 10:35 /home/test/jt/3223kj3.jar
We try also different approach with grep, but this syntax does not return any output:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep "*.jar$"
Where I am wrong?
linux shell-script grep
linux shell-script grep
edited Mar 6 at 18:29


DisplayName
4,63594782
4,63594782
asked Mar 6 at 16:59
yaelyael
2,79332979
2,79332979
closed as unclear what you're asking by G-Man, jimmij, roaima, Mr Shunz, Haxiel Mar 7 at 18:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by G-Man, jimmij, roaima, Mr Shunz, Haxiel Mar 7 at 18:37
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
Well, for one thing you are confusing regex and glob patterns: if you want to grep for lines ending in.jar
trygrep ".jar$"
– steeldriver
Mar 6 at 17:39
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:56
1
(a) first it's incorrect, you would need.*.jar
and (b) second it's superfluous becausegrep
outputs whole lines when a match is found (unless you are using-o
for example)
– steeldriver
Mar 6 at 18:03
2
Why are you usingsu
? What ishdfs
? Basically, why aren't you just runningls /home/test/jt/*.jar
?
– terdon♦
Mar 6 at 18:32
add a comment |
1
Well, for one thing you are confusing regex and glob patterns: if you want to grep for lines ending in.jar
trygrep ".jar$"
– steeldriver
Mar 6 at 17:39
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:56
1
(a) first it's incorrect, you would need.*.jar
and (b) second it's superfluous becausegrep
outputs whole lines when a match is found (unless you are using-o
for example)
– steeldriver
Mar 6 at 18:03
2
Why are you usingsu
? What ishdfs
? Basically, why aren't you just runningls /home/test/jt/*.jar
?
– terdon♦
Mar 6 at 18:32
1
1
Well, for one thing you are confusing regex and glob patterns: if you want to grep for lines ending in
.jar
try grep ".jar$"
– steeldriver
Mar 6 at 17:39
Well, for one thing you are confusing regex and glob patterns: if you want to grep for lines ending in
.jar
try grep ".jar$"
– steeldriver
Mar 6 at 17:39
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:56
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:56
1
1
(a) first it's incorrect, you would need
.*.jar
and (b) second it's superfluous because grep
outputs whole lines when a match is found (unless you are using -o
for example)– steeldriver
Mar 6 at 18:03
(a) first it's incorrect, you would need
.*.jar
and (b) second it's superfluous because grep
outputs whole lines when a match is found (unless you are using -o
for example)– steeldriver
Mar 6 at 18:03
2
2
Why are you using
su
? What is hdfs
? Basically, why aren't you just running ls /home/test/jt/*.jar
?– terdon♦
Mar 6 at 18:32
Why are you using
su
? What is hdfs
? Basically, why aren't you just running ls /home/test/jt/*.jar
?– terdon♦
Mar 6 at 18:32
add a comment |
3 Answers
3
active
oldest
votes
*
is excessful here. In regular expressions, *
is used to specify that the previous symbol can appear any number of times, including 0. Using it without a preceding symbol is pointless, so in this special case grep
looks for the *
symbol itself (in general case you need to precede it with for this purpose).
.
has a special meaning of matching any symbol too, so if you want to cover the situations where there are some bogus extensions like .djar
, or extensionless files ending with jar
, you need to precede it with too.
So, in short, you need just:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep ".jar$"
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:51
1
If you don't care about them, why specify them in the expression? Also, in RE,*
is meaningless without a character class before it;*
means "zero or more of the previous match".
– DopeGhoti
Mar 6 at 18:03
... at least with GNU grep, BRE treats a leading*
a literal, whereas ERE treats it as zero or more occurrences of a leading empty string (which matches everything)
– steeldriver
Mar 6 at 18:19
@yaelgrep
searches for a substring by default. It doesn't care about other symbols if there is enough consequent symbols to match the given pattern. If you want it to match the whole line, the expression should both start with^
and end with$
. In this case, if you want to make sure that file has an actual name besides of the extension, you can check it with[^/].jar$
, which means that any symbol except of directory separator (/
) can appear before the dot.[^
symbol]
is an inversion operator.
– bodqhrohro
Mar 6 at 19:19
add a comment |
With grep -E
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep -E .jar$
It searches in the output of first command all files that end with .jar
No, that will find all lines that end in "any character" thenjar
. For examplefajar
. You wantgrep '.jar$
. But in any case, this is the same as what the OP already did. The-E
doesn't make any difference at all here.
– terdon♦
Mar 6 at 18:34
add a comment |
Try this one:
ls -l | grep *.jar*
Apart from the problems with parsing the output of ls, this will also find names likefoojarbar
. Why not justls -l *.jar
?
– terdon♦
Mar 6 at 18:31
@terdon "ls -l * .jar " will list all files with .doc at the at the end if you wanna list ALL files speicfically which have ".jar" you should use " ls -l * .jar * " this specfically looks for th phrase ".jar" instead of only jar.
– Qasim
Mar 6 at 18:34
I know the formatting here is complicated. Sorry! Please look at the formatting tools help page for help on formatting your posts.
– terdon♦
Mar 6 at 18:38
yea the format is pretty annoying
– Qasim
Mar 6 at 18:39
1
@G-Man Interesting how things are so much clearer after a good nights sleep. You're quite right, of course,ls *.jar
will list files ending in.jar
. My point about the regex was because the OP was usingls | grep .jar
and that does something very different. I just copied the wrong thing into my comment.
– terdon♦
Mar 7 at 16:49
|
show 5 more comments
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
*
is excessful here. In regular expressions, *
is used to specify that the previous symbol can appear any number of times, including 0. Using it without a preceding symbol is pointless, so in this special case grep
looks for the *
symbol itself (in general case you need to precede it with for this purpose).
.
has a special meaning of matching any symbol too, so if you want to cover the situations where there are some bogus extensions like .djar
, or extensionless files ending with jar
, you need to precede it with too.
So, in short, you need just:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep ".jar$"
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:51
1
If you don't care about them, why specify them in the expression? Also, in RE,*
is meaningless without a character class before it;*
means "zero or more of the previous match".
– DopeGhoti
Mar 6 at 18:03
... at least with GNU grep, BRE treats a leading*
a literal, whereas ERE treats it as zero or more occurrences of a leading empty string (which matches everything)
– steeldriver
Mar 6 at 18:19
@yaelgrep
searches for a substring by default. It doesn't care about other symbols if there is enough consequent symbols to match the given pattern. If you want it to match the whole line, the expression should both start with^
and end with$
. In this case, if you want to make sure that file has an actual name besides of the extension, you can check it with[^/].jar$
, which means that any symbol except of directory separator (/
) can appear before the dot.[^
symbol]
is an inversion operator.
– bodqhrohro
Mar 6 at 19:19
add a comment |
*
is excessful here. In regular expressions, *
is used to specify that the previous symbol can appear any number of times, including 0. Using it without a preceding symbol is pointless, so in this special case grep
looks for the *
symbol itself (in general case you need to precede it with for this purpose).
.
has a special meaning of matching any symbol too, so if you want to cover the situations where there are some bogus extensions like .djar
, or extensionless files ending with jar
, you need to precede it with too.
So, in short, you need just:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep ".jar$"
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:51
1
If you don't care about them, why specify them in the expression? Also, in RE,*
is meaningless without a character class before it;*
means "zero or more of the previous match".
– DopeGhoti
Mar 6 at 18:03
... at least with GNU grep, BRE treats a leading*
a literal, whereas ERE treats it as zero or more occurrences of a leading empty string (which matches everything)
– steeldriver
Mar 6 at 18:19
@yaelgrep
searches for a substring by default. It doesn't care about other symbols if there is enough consequent symbols to match the given pattern. If you want it to match the whole line, the expression should both start with^
and end with$
. In this case, if you want to make sure that file has an actual name besides of the extension, you can check it with[^/].jar$
, which means that any symbol except of directory separator (/
) can appear before the dot.[^
symbol]
is an inversion operator.
– bodqhrohro
Mar 6 at 19:19
add a comment |
*
is excessful here. In regular expressions, *
is used to specify that the previous symbol can appear any number of times, including 0. Using it without a preceding symbol is pointless, so in this special case grep
looks for the *
symbol itself (in general case you need to precede it with for this purpose).
.
has a special meaning of matching any symbol too, so if you want to cover the situations where there are some bogus extensions like .djar
, or extensionless files ending with jar
, you need to precede it with too.
So, in short, you need just:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep ".jar$"
*
is excessful here. In regular expressions, *
is used to specify that the previous symbol can appear any number of times, including 0. Using it without a preceding symbol is pointless, so in this special case grep
looks for the *
symbol itself (in general case you need to precede it with for this purpose).
.
has a special meaning of matching any symbol too, so if you want to cover the situations where there are some bogus extensions like .djar
, or extensionless files ending with jar
, you need to precede it with too.
So, in short, you need just:
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep ".jar$"
answered Mar 6 at 17:47


bodqhrohrobodqhrohro
32617
32617
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:51
1
If you don't care about them, why specify them in the expression? Also, in RE,*
is meaningless without a character class before it;*
means "zero or more of the previous match".
– DopeGhoti
Mar 6 at 18:03
... at least with GNU grep, BRE treats a leading*
a literal, whereas ERE treats it as zero or more occurrences of a leading empty string (which matches everything)
– steeldriver
Mar 6 at 18:19
@yaelgrep
searches for a substring by default. It doesn't care about other symbols if there is enough consequent symbols to match the given pattern. If you want it to match the whole line, the expression should both start with^
and end with$
. In this case, if you want to make sure that file has an actual name besides of the extension, you can check it with[^/].jar$
, which means that any symbol except of directory separator (/
) can appear before the dot.[^
symbol]
is an inversion operator.
– bodqhrohro
Mar 6 at 19:19
add a comment |
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:51
1
If you don't care about them, why specify them in the expression? Also, in RE,*
is meaningless without a character class before it;*
means "zero or more of the previous match".
– DopeGhoti
Mar 6 at 18:03
... at least with GNU grep, BRE treats a leading*
a literal, whereas ERE treats it as zero or more occurrences of a leading empty string (which matches everything)
– steeldriver
Mar 6 at 18:19
@yaelgrep
searches for a substring by default. It doesn't care about other symbols if there is enough consequent symbols to match the given pattern. If you want it to match the whole line, the expression should both start with^
and end with$
. In this case, if you want to make sure that file has an actual name besides of the extension, you can check it with[^/].jar$
, which means that any symbol except of directory separator (/
) can appear before the dot.[^
symbol]
is an inversion operator.
– bodqhrohro
Mar 6 at 19:19
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:51
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:51
1
1
If you don't care about them, why specify them in the expression? Also, in RE,
*
is meaningless without a character class before it; *
means "zero or more of the previous match".– DopeGhoti
Mar 6 at 18:03
If you don't care about them, why specify them in the expression? Also, in RE,
*
is meaningless without a character class before it; *
means "zero or more of the previous match".– DopeGhoti
Mar 6 at 18:03
... at least with GNU grep, BRE treats a leading
*
a literal, whereas ERE treats it as zero or more occurrences of a leading empty string (which matches everything)– steeldriver
Mar 6 at 18:19
... at least with GNU grep, BRE treats a leading
*
a literal, whereas ERE treats it as zero or more occurrences of a leading empty string (which matches everything)– steeldriver
Mar 6 at 18:19
@yael
grep
searches for a substring by default. It doesn't care about other symbols if there is enough consequent symbols to match the given pattern. If you want it to match the whole line, the expression should both start with ^
and end with $
. In this case, if you want to make sure that file has an actual name besides of the extension, you can check it with [^/].jar$
, which means that any symbol except of directory separator (/
) can appear before the dot. [^
symbol ]
is an inversion operator.– bodqhrohro
Mar 6 at 19:19
@yael
grep
searches for a substring by default. It doesn't care about other symbols if there is enough consequent symbols to match the given pattern. If you want it to match the whole line, the expression should both start with ^
and end with $
. In this case, if you want to make sure that file has an actual name besides of the extension, you can check it with [^/].jar$
, which means that any symbol except of directory separator (/
) can appear before the dot. [^
symbol ]
is an inversion operator.– bodqhrohro
Mar 6 at 19:19
add a comment |
With grep -E
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep -E .jar$
It searches in the output of first command all files that end with .jar
No, that will find all lines that end in "any character" thenjar
. For examplefajar
. You wantgrep '.jar$
. But in any case, this is the same as what the OP already did. The-E
doesn't make any difference at all here.
– terdon♦
Mar 6 at 18:34
add a comment |
With grep -E
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep -E .jar$
It searches in the output of first command all files that end with .jar
No, that will find all lines that end in "any character" thenjar
. For examplefajar
. You wantgrep '.jar$
. But in any case, this is the same as what the OP already did. The-E
doesn't make any difference at all here.
– terdon♦
Mar 6 at 18:34
add a comment |
With grep -E
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep -E .jar$
It searches in the output of first command all files that end with .jar
With grep -E
su -l hdfs -c " hdfs dfs -ls /home/test/jt" | grep -E .jar$
It searches in the output of first command all files that end with .jar
answered Mar 6 at 18:25
Emilio GalarragaEmilio Galarraga
554410
554410
No, that will find all lines that end in "any character" thenjar
. For examplefajar
. You wantgrep '.jar$
. But in any case, this is the same as what the OP already did. The-E
doesn't make any difference at all here.
– terdon♦
Mar 6 at 18:34
add a comment |
No, that will find all lines that end in "any character" thenjar
. For examplefajar
. You wantgrep '.jar$
. But in any case, this is the same as what the OP already did. The-E
doesn't make any difference at all here.
– terdon♦
Mar 6 at 18:34
No, that will find all lines that end in "any character" then
jar
. For example fajar
. You want grep '.jar$
. But in any case, this is the same as what the OP already did. The -E
doesn't make any difference at all here.– terdon♦
Mar 6 at 18:34
No, that will find all lines that end in "any character" then
jar
. For example fajar
. You want grep '.jar$
. But in any case, this is the same as what the OP already did. The -E
doesn't make any difference at all here.– terdon♦
Mar 6 at 18:34
add a comment |
Try this one:
ls -l | grep *.jar*
Apart from the problems with parsing the output of ls, this will also find names likefoojarbar
. Why not justls -l *.jar
?
– terdon♦
Mar 6 at 18:31
@terdon "ls -l * .jar " will list all files with .doc at the at the end if you wanna list ALL files speicfically which have ".jar" you should use " ls -l * .jar * " this specfically looks for th phrase ".jar" instead of only jar.
– Qasim
Mar 6 at 18:34
I know the formatting here is complicated. Sorry! Please look at the formatting tools help page for help on formatting your posts.
– terdon♦
Mar 6 at 18:38
yea the format is pretty annoying
– Qasim
Mar 6 at 18:39
1
@G-Man Interesting how things are so much clearer after a good nights sleep. You're quite right, of course,ls *.jar
will list files ending in.jar
. My point about the regex was because the OP was usingls | grep .jar
and that does something very different. I just copied the wrong thing into my comment.
– terdon♦
Mar 7 at 16:49
|
show 5 more comments
Try this one:
ls -l | grep *.jar*
Apart from the problems with parsing the output of ls, this will also find names likefoojarbar
. Why not justls -l *.jar
?
– terdon♦
Mar 6 at 18:31
@terdon "ls -l * .jar " will list all files with .doc at the at the end if you wanna list ALL files speicfically which have ".jar" you should use " ls -l * .jar * " this specfically looks for th phrase ".jar" instead of only jar.
– Qasim
Mar 6 at 18:34
I know the formatting here is complicated. Sorry! Please look at the formatting tools help page for help on formatting your posts.
– terdon♦
Mar 6 at 18:38
yea the format is pretty annoying
– Qasim
Mar 6 at 18:39
1
@G-Man Interesting how things are so much clearer after a good nights sleep. You're quite right, of course,ls *.jar
will list files ending in.jar
. My point about the regex was because the OP was usingls | grep .jar
and that does something very different. I just copied the wrong thing into my comment.
– terdon♦
Mar 7 at 16:49
|
show 5 more comments
Try this one:
ls -l | grep *.jar*
Try this one:
ls -l | grep *.jar*
edited Mar 6 at 18:38
terdon♦
133k32266446
133k32266446
answered Mar 6 at 18:27


QasimQasim
19
19
Apart from the problems with parsing the output of ls, this will also find names likefoojarbar
. Why not justls -l *.jar
?
– terdon♦
Mar 6 at 18:31
@terdon "ls -l * .jar " will list all files with .doc at the at the end if you wanna list ALL files speicfically which have ".jar" you should use " ls -l * .jar * " this specfically looks for th phrase ".jar" instead of only jar.
– Qasim
Mar 6 at 18:34
I know the formatting here is complicated. Sorry! Please look at the formatting tools help page for help on formatting your posts.
– terdon♦
Mar 6 at 18:38
yea the format is pretty annoying
– Qasim
Mar 6 at 18:39
1
@G-Man Interesting how things are so much clearer after a good nights sleep. You're quite right, of course,ls *.jar
will list files ending in.jar
. My point about the regex was because the OP was usingls | grep .jar
and that does something very different. I just copied the wrong thing into my comment.
– terdon♦
Mar 7 at 16:49
|
show 5 more comments
Apart from the problems with parsing the output of ls, this will also find names likefoojarbar
. Why not justls -l *.jar
?
– terdon♦
Mar 6 at 18:31
@terdon "ls -l * .jar " will list all files with .doc at the at the end if you wanna list ALL files speicfically which have ".jar" you should use " ls -l * .jar * " this specfically looks for th phrase ".jar" instead of only jar.
– Qasim
Mar 6 at 18:34
I know the formatting here is complicated. Sorry! Please look at the formatting tools help page for help on formatting your posts.
– terdon♦
Mar 6 at 18:38
yea the format is pretty annoying
– Qasim
Mar 6 at 18:39
1
@G-Man Interesting how things are so much clearer after a good nights sleep. You're quite right, of course,ls *.jar
will list files ending in.jar
. My point about the regex was because the OP was usingls | grep .jar
and that does something very different. I just copied the wrong thing into my comment.
– terdon♦
Mar 7 at 16:49
Apart from the problems with parsing the output of ls, this will also find names like
foojarbar
. Why not just ls -l *.jar
?– terdon♦
Mar 6 at 18:31
Apart from the problems with parsing the output of ls, this will also find names like
foojarbar
. Why not just ls -l *.jar
?– terdon♦
Mar 6 at 18:31
@terdon "ls -l * .jar " will list all files with .doc at the at the end if you wanna list ALL files speicfically which have ".jar" you should use " ls -l * .jar * " this specfically looks for th phrase ".jar" instead of only jar.
– Qasim
Mar 6 at 18:34
@terdon "ls -l * .jar " will list all files with .doc at the at the end if you wanna list ALL files speicfically which have ".jar" you should use " ls -l * .jar * " this specfically looks for th phrase ".jar" instead of only jar.
– Qasim
Mar 6 at 18:34
I know the formatting here is complicated. Sorry! Please look at the formatting tools help page for help on formatting your posts.
– terdon♦
Mar 6 at 18:38
I know the formatting here is complicated. Sorry! Please look at the formatting tools help page for help on formatting your posts.
– terdon♦
Mar 6 at 18:38
yea the format is pretty annoying
– Qasim
Mar 6 at 18:39
yea the format is pretty annoying
– Qasim
Mar 6 at 18:39
1
1
@G-Man Interesting how things are so much clearer after a good nights sleep. You're quite right, of course,
ls *.jar
will list files ending in .jar
. My point about the regex was because the OP was using ls | grep .jar
and that does something very different. I just copied the wrong thing into my comment.– terdon♦
Mar 7 at 16:49
@G-Man Interesting how things are so much clearer after a good nights sleep. You're quite right, of course,
ls *.jar
will list files ending in .jar
. My point about the regex was because the OP was using ls | grep .jar
and that does something very different. I just copied the wrong thing into my comment.– terdon♦
Mar 7 at 16:49
|
show 5 more comments
6Lftc5g6Le fHpw58PTXpGp,MWL8lQPLgy2P4Pyv
1
Well, for one thing you are confusing regex and glob patterns: if you want to grep for lines ending in
.jar
trygrep ".jar$"
– steeldriver
Mar 6 at 17:39
but what about all words before .jar , so why not set *.jar$
– yael
Mar 6 at 17:56
1
(a) first it's incorrect, you would need
.*.jar
and (b) second it's superfluous becausegrep
outputs whole lines when a match is found (unless you are using-o
for example)– steeldriver
Mar 6 at 18:03
2
Why are you using
su
? What ishdfs
? Basically, why aren't you just runningls /home/test/jt/*.jar
?– terdon♦
Mar 6 at 18:32