awk seems to be wrongly placed?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk seems to be wrongly placed?
# 1  
Old 03-10-2015
awk seems to be wrongly placed?

Dear all,
I have small script ( which after introducing few changes) is not working as desired way [1].

The content of the output file from this script is following
-----------
Code:
    1492033600 /pnfs/desy.de/cms/tier2/store/user/emily/L1Trigger/HOUpgrade/Generation/SingleMuonGun/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V3_GEN_SIM_DIGI_RECO_L1/150127_084421/0001/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V1_GEN_SIM_DIGI_RECO_L1_1271.root
      1487504182 /pnfs/desy.de/cms/tier2/store/user/emily/L1Trigger/HOUpgrade/Generation/SingleMuonGun/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V3_GEN_SIM_DIGI_RECO_L1/150127_084421/0001/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V1_GEN_SIM_DIGI_RECO_L1_1994.root


However, I wanted the 'AWK' command to work and provide me following output:
Code:
---------------/store/user/emily/L1Trigger/HOUpgrade/Generation/SingleMuonGun/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V3_GEN_SIM_DIGI_RECO_L1/150127_084421/0001/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V1_GEN_SIM_DIGI_RECO_L1_1271.root
 /store/user/emily/L1Trigger/HOUpgrade/Generation/SingleMuonGun/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V3_GEN_SIM_DIGI_RECO_L1/150127_084421/0001/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V1_GEN_SIM_DIGI_RECO_L1_1994.root

Please suggest what went wrong..? Smilie Smilie
emily,

[1]
------------------------------
Code:
#!/bin/bash                                                                                                                                                                                                    

OUTPUT=InputFile_
GREP=root
EOSPATH="srm://dcache-se-cms.desy.de:8443/pnfs/desy.de/cms/tier2//store/user/emily/L1Trigger/HOUpgrade/Generation/SingleMuonGun/SingleMuMinus_Fall14_FlatPt-0to200_MCRUN2_72_V3_GEN_SIM_DIGI_RECO_L1/150127_\
084421/"
FILEPATH[1]=$EOSPATH/0001
#FILEPATH[2]=$EOSPATH/0002                                                                                                                                                                                     
                                                                                                                                                                      
### copy the FileName from eos to $3                                                                                                                                                                           
CopyFileNameFromCastor()  {
    for FileNameIndx in "${FILEPATH[@]}"
    do
        if [[ ! -e "dest_path/$FileNameIndx" ]]; then
            Index=$(echo $FileNameIndx | awk '{split($FileNameIndx, a, "/00"); print "0"a[2]}')
            echo "Copying fileName \"$FileNameIndx  | grep root\" to $OUTPUT$Index"
            srmls $FileNameIndx --count 99999 --offset 2 | grep "$GREP" | awk -F'tier2' '{print string path $GREP}' string="" path=""  > $OUTPUT$Index
            FINALFILE=$OUTPUT$Index

            echo "progressing ... please be patient..."

            ### split the files into small files for job submittion                                                                                                                                            
            awk '                                                                                                                                                                                              
            NR==1 {outfile = sprintf("%s_%01d.txt", FILENAME, 0)                                                                                                                                               
            }                                                                                                                                                                                                  
            {print > outfile                                                                                                                                                                                   
            }                                                                                                                                                                                                  
            (NR % 200) == 0 {                                                                                                                                                                                  
            close(outfile)                                                                                                                                                                                     
            outfile = sprintf("%s_%01d.txt", FILENAME, int(NR/200))                                                                                                                                            
            }'  $FINALFILE
        fi
    done
    rm -f ${OUTPUT}*[0-9][0-9][0-9]
}

---------- Post updated at 08:24 AM ---------- Previous update was at 08:15 AM ----------

I modified this as following:
Code:
            srmls $FileNameIndx --count 99999 --offset 2 | grep "$GREP" | awk '{split($FileNameIndx, a, "tier2"); print a[2]}' > $OUTPUT$Index

ans its working fine...Smilie Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command within script wrongly deleting the last line

Hi, I have a shell script which has a for loop that scans list of files and do find and replace few variables using sed command. While doing this, it deletes the last line of all input file which is something wrong. how to fix this. please suggest. When i add an empty line in all my input file,... (5 Replies)
Discussion started by: rbalaj16
5 Replies

2. Shell Programming and Scripting

REGEXPRESSION Getting wrongly

Hello Experts, My requirement is to read a file which contains regular expression and use that expression in my find command.I will not use all the regular expression which is there inside the file, Based on certain condition I will use it for that day. I used below regular expression inside a... (6 Replies)
Discussion started by: gvkumar25
6 Replies

3. Solaris

How to recover wrongly deleted volume in VxVM?

Hi On solaris 10 system my one veritas volume got accidently deleted. Now could any one tell me how to recover it. If I am taking regular backup of disk group of that volume through vxconfigbackup as I want to recover only particular volume only. (1 Reply)
Discussion started by: amity
1 Replies

4. Post Here to Contact Site Administrators and Moderators

Please delete my post which was posted wrongly

Hi Moderator, Please delete the below post which i posted by mistake.Thanks in advance. https://www.unix.com/shell-programming-and-scripting/260605-closed-script-not-working-new-post.html Kindly help me on this. Thanks, vijay (1 Reply)
Discussion started by: bhas85
1 Replies

5. Shell Programming and Scripting

awk output yields error: awk:can't open job_name (Autosys)

Good evening, Im newbie at unix specially with awk From an scheduler program called Autosys i want to extract some data reading an inputfile that comprises jobs names, then formating the output to columns for example 1. This is the inputfile: $ more MapaRep.txt ds_extra_nikira_usuarios... (18 Replies)
Discussion started by: alexcol
18 Replies

6. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

7. Red Hat

Putty recognise keystroke wrongly!

Putty: release 0.58 Operating system: Linux, release 2.6.36-rc7 Problem: I use Putty to connet to server, initially everthing looks fine but after I browse some files, my keyboard acts funny, like if I keyin "cd", I got "je" on the screen. :wall: This only happens on some existing files but... (4 Replies)
Discussion started by: linwufei125
4 Replies

8. Shell Programming and Scripting

Awk problem: How to express the single quote(') by using awk print function

Actually I got a list of file end with *.txt I want to use the same command apply to all the *.txt Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics. For example: I got the file below: file1.txt file2.txt file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies

9. UNIX for Dummies Questions & Answers

wrongly linked my new file ..

Hi All, I was trying to point /unix-> new unix kernel ( unix_64_A ).. but instead by mistakenly i did the other way ..my new unix ( unix_64_A -> /unix ) ?? .. unfortunately i have only one copy of unix_64_A ..is there any way to solve this problem ..please help me asap . Thanks Vamshi. (4 Replies)
Discussion started by: siddaonline
4 Replies

10. Solaris

wrongly encapsulated appdg instead of rootdg

hi guys, i was doing a fresh installation of vxvm 4.0 on solaris 8 Sun enterprise 3500 and when i ran vxinstall command it gave me option of appdg and appdg02 to be encapsulated . I wanted to encapsulate rootdg. i wrongly encapsulated appdg. is there any work around for this ? your response... (5 Replies)
Discussion started by: ishila
5 Replies
Login or Register to Ask a Question