Differentiate 2 files name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Differentiate 2 files name
# 8  
Old 04-10-2015
Let awk split on _ and print if the number of fields is less than 6:
Code:
 ls *.zip | awk -F_ 'NF<6'
MYTEST001_RKP_DORALDO_20150402120000.zip

# 9  
Old 04-20-2015
RedHat Differentiat 2 files depending on naming Covention

Thanks to all for quick reply. But I am getting some problem because of difference in Unix and Linux option available for command.

I have 2 set of file..

First Set these should be treated seperatly
Code:
EFC10668_LAB_COVANCE_20150415120000.dat
EFC10668_LAB_COVANCE_20150415120000_1.dat
EFC10668_LAB_COVANCE_20150415120000_C.dat

Second Set these should be treated differently
Code:
AVE0005_EFC10668_COVANCE_LABL_20150409.dat
AVE0005_EFC10668_COVANCE_LABL_20150409_C.dat
AVE0005_EFC10668_COVANCE_LABL_20150409_1.dat

In linux i am counting the _ in filename but in HP UX I am able find any option.

Code:
grep -o

currently I am using below If condition to separate but I thing it is not going to work properly.

Code:
if [ "$(ls $n_filezip_name | awk '{FS="_"}  $5~/[0-9]{8}/')" = "" ];

Can someone help on this.
# 10  
Old 04-20-2015
I believe, counting of "_" is quite posixish:

Code:
echo "a_b_c_d" | awk -F_ '{print NF-1}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare and Differentiate Multiple Files

Im using code below comparing and getting the diff of two files. But what about multiple files? can you help me guys diff -u file1 file2|sed -n '/^---/!{/^-/s/-//p}' diff -ui file1 file2| sed -n '/^++/!{/^+/s/+//p}' Example File1: aaa bbb ccc ddd File2: bbb eee (5 Replies)
Discussion started by: kenshinhimura
5 Replies

2. Shell Programming and Scripting

How to differentiate between two machine in Unix?

how to differentiate between two machine in Unix,whether it is logged in from local machine or from Server( both may be 2 or more). Please help. (5 Replies)
Discussion started by: kpatel97
5 Replies

3. UNIX for Dummies Questions & Answers

differentiate $@ and $*

can anyone explain the difference between $* and $@? pandeeswaran@ubuntu:~/training$ bash dollarstar 1 2 3 "4 5" 6 1 2 3 4 5 6 1 2 3 4 5 6 pandeeswaran@ubuntu:~/training$ cat dollarstar #!/bin/bash for i in $@ do (4 Replies)
Discussion started by: pandeesh
4 Replies

4. Shell Programming and Scripting

differentiate between spaces and new-lines

Hi - Here's the problem I'm encountering......My script logs in to remote FTP through password-less "sftp" and must get the list of sub-directories under a given path. I know many of the unix commands don't work in "sftp" login so I cannot know which one is a "directory" and which one is a... (2 Replies)
Discussion started by: dips_ag
2 Replies

5. UNIX and Linux Applications

Differentiate between MS Word and Excel files in Unix

Hi, I want to differentiate between a MS Word and Excel file in Unix (not by extension). The condition which we are currently checking for is the pattern "\320\317\021\340" within first 40 bytes of the file. However this format is same in all MS Office files. Can somebody tell me any special... (4 Replies)
Discussion started by: phatak_rajan
4 Replies

6. Shell Programming and Scripting

Differentiate the scripts

Can anyone decribe what would be differnce between the following scripts: #nohup /bin/sh ./job 2>& 1& # ./job > nohup.out & Thanks Alvida (1 Reply)
Discussion started by: alvida
1 Replies

7. Shell Programming and Scripting

How to differentiate two tar files

Hi All, I am new to this unix stuff.I just have one doubt:suppose i have two tar files and sometimes it happens that when we just check these files from outside these two tar files look same "Eg: ls -lrt drw-r--r-- 1 oasis logadmin 37067 Apr 3 05:48 file1.tar drw-r--r-- 1 oasis ... (7 Replies)
Discussion started by: siri_14
7 Replies

8. UNIX for Dummies Questions & Answers

differentiate between a file and a device

sorry probably a beginner question but i was just wondering how unix does this as device are treated as files? (6 Replies)
Discussion started by: keith_hampson
6 Replies

9. UNIX for Dummies Questions & Answers

how to differentiate a file from a folder in a FIND?

I have to read a complete folder and if it is a file older that 7 days I have to copy it elsewhere and if it is a folder nothing to make. The way I do it: for I in `find /home/. -name "*" -mtime +7` do cp -Rf $I /home/elsewhere/. done Am I okay with the way I want to do it? Help... (3 Replies)
Discussion started by: denysQC
3 Replies

10. UNIX for Dummies Questions & Answers

How to Differentiate Between Files and Folders?

Hi All, I'm a rookie using HPUX and I know this is going to sound like a bonehead question, but when I list the contents of a directory, how can I determine which objects are files and which are folders? I'm using the ll and ls commands to lists the contents. So far I've been determining the... (6 Replies)
Discussion started by: dgower2
6 Replies
Login or Register to Ask a Question