Sponsored Content
Full Discussion: Help with selective ls
Top Forums UNIX for Dummies Questions & Answers Help with selective ls Post 302617849 by newbie_01 on Tuesday 3rd of April 2012 07:27:45 AM
Old 04-03-2012
Thanks. That one works so far on :Linux. Hope the same thing works on Solaris.

---------- Post updated at 06:27 AM ---------- Previous update was at 06:18 AM ----------

Thanks to everyone who responded.

So far, yazu's suggestion is what am trialing out.

Code:
ls | egrep 'log_[0-9]+\.xml'

Also found the link below useful, in case egrep does not function like it used to on other *nixes or on others where egrep is not available.

https://www.unix.com/shell-programmin...ric-value.html

FYI, my other chosen alternative which is using awk if egrep is not available is as below. Any awk expert around to make it "shorter"

Code:
ls -1tr *.xml | awk -F. '{ print $1 }' | awk -F_ '{ print $2 }' | awk '/^[0-9]+$/' | awk '{ print "log_"$1".xml" }'

or for .txt files

ls -1tr *.txt | awk -F. '{ print $1 }' | awk -F_ '{ print $2 }' | awk '/^[0-9]+$/' | awk '{ print "log_"$1".xml" }'

Thanks again everyone. Very much appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

echo is selective?

i tried to ask about this earlier, but didn't explain well enough. From a script, i issue the following: echo `pgp --encrypt filename --recipient public-key` The result is perfect. The encrypted file is in the directory just as if i'd issued the pgp command from the command line. However,... (0 Replies)
Discussion started by: rgard
0 Replies

2. UNIX for Advanced & Expert Users

Selective Umask

Hi, We have umask 022 in /etc/profile for security reasons. But I want have some other umask for selected users. how to achieve this? Regards (3 Replies)
Discussion started by: baanprog
3 Replies

3. IP Networking

selective masquerading

I am running Linux 2.6.20 on i686 architecture. I want to be able to masquerade different hosts on my LAN to different external interfaces. Specifically, I want one specific host to masquerade through a vpn tunnel while the other hosts simply masquerade over the regular ISP interface. I only... (4 Replies)
Discussion started by: NESter
4 Replies

4. Shell Programming and Scripting

selective printing

hi all from below text "abcd,SYS_12345,xyz,PQR, ," I want to print only "abcd,SYS,xyz,PQR, ," i.e. taking only first three 3 chars from 2 string of comma separated file thanks (4 Replies)
Discussion started by: JoeColeEPL9
4 Replies

5. UNIX for Dummies Questions & Answers

selective grep

Hello, I have been using the command below for file manipulation. while read A B; do grep $f1; done < f2 > f3 So, if a certain string is found in f2 (for ex; DOG243435) and it is also present in f1, then print that string plus the contents of the line in which it was found onto f3. ... (6 Replies)
Discussion started by: verse123
6 Replies

6. Shell Programming and Scripting

Selective grep

I have to grep out only email address from a column. It has characters appended and prepended F=<sss1@domain.com> <sss2@domain.com> (sss3@domain.com) <sss4@domain.com> Whatever added before and after email, I should be able to grep out only emails. (9 Replies)
Discussion started by: anil510
9 Replies

7. Shell Programming and Scripting

Selective grouping

I have a text file in this format. Group: AAA Notes: IP : 11.11.11.11 #User xxxxxxxxx #Password aaaaaaaaaaaaaaaa Group: AAA Notes: IP : 11.11.11.22 #User yyyyyyyyyyyyy #Password bbbbbbbbbbbbb (8 Replies)
Discussion started by: anil510
8 Replies

8. UNIX for Dummies Questions & Answers

Selective replace

i have a large sequence of format sat_1_g3_g_0_8540 . A 1 15501 . . . ID=sat_1_g3_g_0_8540;parentName=sat_1_g3_g_0_8540;Al=sat_1_g2_g_0_8540; sat_1_g3_g_2_8510 . C 1 25501 . . . ... (11 Replies)
Discussion started by: siya@
11 Replies

9. Shell Programming and Scripting

Selective printing

I have the following contents in a file ---- CRITICAL: altered for /usr/bin/bin1 ---- OK: /usr/sbin/bin2 result fine ---- OK: /usr/sbin/bin3 result fine ---- CRITICAL: altered for /usr/bin/bin4 ---- OK: /usr/bin/bin5 result fine ---- OK: /usr/bin/bin6 result fine ---- CRITICAL: altered for... (9 Replies)
Discussion started by: anil510
9 Replies

10. Shell Programming and Scripting

Selective running

I have MegaCli64 -PDList -aALL | grep -E 'Enclosure Device ID|Slot Number' Enclosure Device ID: 252 Slot Number: 0 Enclosure Device ID: 252 Slot Number: 1 Enclosure Device ID: 252 Slot Number: 2 Enclosure Device ID: 252 Slot Number: 3 I need to run the following command on all slots... (4 Replies)
Discussion started by: anil510
4 Replies
TAU_DUMP_FUNC_VALS_I(3) 				      TAU Instrumentation API					   TAU_DUMP_FUNC_VALS_I(3)

NAME
TAU_DUMP_FUNC_VALS_INCR - Dumps function values with a timestamp SYNOPSIS
C/C++: TAU_DUMP_FUNC_VALS_INCR(char **inFuncs, int numFuncs); DESCRIPTION
Similar to TAU_DUMP_FUNC_VALS. This macro creates an incremental selective dump and dumps the results with a date stamp to the filename such as sel_dump__Thu-Mar-28-16:30:48-2002__.0.0.0. In this manner the previous TAU_DUMP_FUNC_VALS_INCR(...) are not overwritten (unless they occur within a second). EXAMPLE
C/C++ : const char **inFuncs; /* The first dimension is functions, and the second dimension is counters */ double **counterExclusiveValues; double **counterInclusiveValues; int *numOfCalls; int *numOfSubRoutines; const char **counterNames; int numOfCouns; TAU_GET_FUNC_VALS(inFuncs, 2, counterExclusiveValues, counterInclusiveValues, numOfCalls, numOfSubRoutines, counterNames, numOfCouns); TAU_DUMP_FUNC_VALS(inFuncs, 2); SEE ALSO
TAU_DB_DUMP(3), TAU_DUMP_FUNC_NAMES(3), TAU_DUMP_FUNC_VALS(3) 08/31/2005 TAU_DUMP_FUNC_VALS_I(3)
All times are GMT -4. The time now is 05:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy