How to use cut or sed for my little script.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to use cut or sed for my little script.
# 1  
Old 04-28-2010
Question How to use cut or sed for my little script.

Hello people,

I have a little script that has to compare some files (exe files)... so i find all the files in the given paths (2 paths) and it generates 2 txt files (named 1.txt and 2.txt, they have to be identical) i need to have a little IF function to compare the 2 files and see if they are the same and if not to stop, the problem is that i dont know how exclude from my txt files all the things and leave only the name.exe files, the path can differ everytime and i dont know extract only the *.exe files.

After i do this i want to compare (using cmp command ) the the files in those 2 .txt files , cmp /etc/etc/etc/file.exe /etc/etc/sd/asd/asd/file.exe

How can i apply cmp on those files automatically ?

If someone can i help me i thank him.

Regards
# 2  
Old 04-28-2010
Where is the script?
Quote:
i dont know extract only the *.exe files
Whats wrong with ls *.exe ? Is it because you want one file per line?
What do you call different? size? timestamp? owner ? permission?
...
# 3  
Old 04-29-2010
Thank you for your interesnt in helping me, i have managed to solve it by myself. I will post that part for who needs it .
Code:
cat EXE_FILES_[$FIRSTPATH].txt > exe1.txt
cat EXE_FILES_[$SECONDPATH].txt > exe2.txt

echo "#!/bin/ksh" > files.txt

paste -d, exe1.txt exe2.txt | sed 's/,/ /g' > files.txt

rm -rf exe1.txt exe2.txt 

awk '{print "cmp " $0 }' files.txt > cmp.sh

rm -rf files.txt

chmod a+x cmp.sh

echo "Running CMP test..."

echo " "

./cmp.sh > results-cmp.txt

I'm sure that the code is not very "clean" but it works (thanks God) Smilie.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. Shell Programming and Scripting

Ping - cut and sed - problem

How can I get the following result of the "ping" command? Example: root@OpenWrt:~# ping google.com -c1 | sed -n 1p PING google.com (216.58.210.14): 56 data bytes How can I get the data only in the range of ()? The result of what I want to get it: 216.58.210.14 Please use code... (4 Replies)
Discussion started by: andrewxxx
4 Replies

3. Shell Programming and Scripting

sed should cut seconds

Hi! I need help to modify a comma-sep. file. I tried to cut the secons of a timestamp. ... 11,05/15/12,13:20:00,Raw Counts,58313,5280,6967 13,05/15/12,13:40:00,Raw Counts,70637,6592,8648 ... it should be: 11,05/15/12,13:20,Raw Counts,58313,5280,6967 13,05/15/12,13:40,Raw... (5 Replies)
Discussion started by: IMPe
5 Replies

4. Shell Programming and Scripting

sed cut columns

hello everyone ! i face the following problem as i use sed to ignore some columns of an output. the command i use is sed 's/^\(*\) \(*\).*/\1 \2/' as i only want the 2 first columns the command finger returns the problem is that for some lines the results are fine but for other lines... (8 Replies)
Discussion started by: vlm
8 Replies

5. Shell Programming and Scripting

how to cut string with wildcard (sed)

i got text file and contain.... SKYPE Dec 11 09:26:05 IN=eth0 OUT=eth1 SRC=75.38.161.80 DST=192.168.1.56 PROTO=UDP SPT=30645 DPT=12630 LEN=66 SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=118.109.39.86 PROTO=UDP SPT=12630 DPT=15889 LEN=75 SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0... (2 Replies)
Discussion started by: slackman
2 Replies

6. Shell Programming and Scripting

cut in sed/awk

Hi Can i have an example where i should be able to cut columns (like for eg cut -c 1-3) in sed or awk. Regards Dhana (12 Replies)
Discussion started by: dhanamurthy
12 Replies

7. Shell Programming and Scripting

Help in SED and CUT.

Hi I have a file. In Each and every line, i want to cut the position from 130 to 134 and need to check if it is XXXX then i need to replace with YYYY (Only from 130 to 134). Your help is very much appriciated. (4 Replies)
Discussion started by: senthil_is
4 Replies

8. Shell Programming and Scripting

cut sed grep or other?

Hi Is there a way to cut the last two characters off a word or number given that this word or number can be of varying length? I have tried something like TEST=`echo $OLD | cut -c 1-5` where $OLD is a variable containing a number like 1234567 which gives a result of 12345. This is fine... (4 Replies)
Discussion started by: rleebife
4 Replies

9. Shell Programming and Scripting

SED and Cut question

I am trying to cut and delete using sed and redirect back into the file. This is not working write. When testing the script, it hangs. Any idea what I am doing wrong here. ################ Reads the input file to cut volumes for returns and CUT_ERVTAPE_FILE() { echo "working on cut... (2 Replies)
Discussion started by: gzs553
2 Replies

10. UNIX for Dummies Questions & Answers

cut vs. sed vs. awk ?

hi again...need new help guys:p the file contains following infos... users/abc/bla1.exe newusers/defgh/ik/albg2.exe users2/opww/ertz/qqwertzu/rwerwew.exe how to get the file content into... users/abc/ newusers/defgh/ik/ users2/opww/ertz/qqwertzu/ with... you can erase the... (5 Replies)
Discussion started by: svennie
5 Replies
Login or Register to Ask a Question