Sponsored Content
Top Forums Shell Programming and Scripting Bash looking in different directory for file that isn't referenced in command Post 302991157 by cmccabe on Tuesday 7th of February 2017 08:47:28 AM
Old 02-07-2017
Bash looking in different directory for file that isn't referenced in command

When I run the below bash I get the expected output, which is the sum of all matching targets less than 20 in $file1. The filename in the directory is fixed (in bold).

Code:
for file1 in /home/cmccabe/Desktop/test/panel/reads/16-0000_EPIL70.txt ; do
        bname=`basename $file1`
        pref=${bname%%_*.txt}
     awk '{gsub(/[()]/,_)} \
count[$5]==""{ count[$5]=0 } 
            $7 < 20{ count[$5]++} 
END{
              for(k in count) 
                 printf "%s %d\n",  k, count[k]
}' $file1 > /home/cmccabe/Desktop/test/panel/20x/base/16-0000_allepil70.bed
done

The desired bash is the exact same except the unique numerical digits, 16-0000 are read into a variable {pref}. This is because there can be multiple files with the same extension, but the digits are always unique.

Code:
for file1 in /home/cmccabe/Desktop/test/panel/reads/${pref}_EPIL70.txt ; do
        bname=`basename $file1`
        pref=${bname%%_*.txt}
     awk '{gsub(/[()]/,_)} \
count[$5]==""{ count[$5]=0 } 
            $7 < 20{ count[$5]++} 
END{
              for(k in count) 
                 printf "%s %d\n",  k, count[k]
}' $file1 > /home/cmccabe/Desktop/test/panel/20x/base/${pref}_allepil70.bed
done

awk: fatal: cannot open file `/home/cmccabe/Desktop/test/panel/reads/16-0000_epil70lessthan20xregions.txt_EPIL70.txt' for reading

The file that it is looking for is not in that directory, but not sure why it is even looking for it as I do not reference it at all in the command or do I? Thank you Smilie.

Code:
ls -l /home/cmccabe/Desktop/test/panel/reads
total 10952
-rw-rw-r-- 1 cmccabe cmccabe 11214550 Feb  7 07:27 16-0000_EPIL70.txt


Last edited by cmccabe; 02-07-2017 at 11:49 AM.. Reason: fixed format,
 

10 More Discussions You Might Find Interesting

1. Solaris

bash: ./<scriptname>: No such file or directory

I have simply downloaded a file to my local folder, made one small change and uploaded it back, ever since it will not run the file. I have now uploaded the original, unchanged file, which still doesn;t work. Evertime it is run ot says bash: ./nrcardprint: No such file or directory The... (10 Replies)
Discussion started by: Heidi.Ebbs
10 Replies

2. UNIX for Dummies Questions & Answers

deleting file that isn't really there

sorry about the title - I have a directory where a file is showing with ls or ls -l but if I try to reference it - I get the message that it isn't there. It is as if the directory structure isn't matching the actual content. Right now, I have two files of same name showing in the... (4 Replies)
Discussion started by: LisaS
4 Replies

3. Programming

Error: Undefined Symbol ..... First referenced in file......

Hi, I am working with Solaris 5.9 and I am newbie in Socket programming and I stated working with socket programming and I copyed a simple client & server program from a website which I am attaching with this and when I am compiling these files.I am getting the error-- Please Help me to... (1 Reply)
Discussion started by: smartgupta
1 Replies

4. Shell Programming and Scripting

[bash] reassigning referenced variables in functions

Hello all, Problem. ---------- I'm trying to reassign a referenced variable passed to a 'local' variable in a function but the local variable refuses to be assigned the content of the referenced variable. Any ideas would be appreciated. Objective. ----------- Eliminate all $VAR... (1 Reply)
Discussion started by: ASGR
1 Replies

5. Linux

bash:umount/: no such file or directory

I am trying to connect two system (let's say for time being) together such that it supports clustering. for this I got the following packages: # sudo apt-get install pacemaker sysv-rc-conf glusterfs-server glusterfs-examples glusterfs-client chkconfig nmap ntp Next, I did... (0 Replies)
Discussion started by: dr_mabuse
0 Replies

6. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

7. Shell Programming and Scripting

Bash to delete file in directory

Will the below bash delete all the "snps.ivg" in the given directory? Thank you :) find N:\all_array\Samples -maxdepth 1 -type f -name "snps.ivg" -delete (6 Replies)
Discussion started by: cmccabe
6 Replies

8. Shell Programming and Scripting

Rename specific file extension in directory with match to another file in bash

I have a specific set (all ending with .bam) of downloaded files in a directory /home/cmccabe/Desktop/NGS/API/2-15-2016. What I am trying to do is use a match to $2 in name to rename the downloaded files. To make things a more involved the date of the folder is unique and in the header of name... (1 Reply)
Discussion started by: cmccabe
1 Replies

9. UNIX for Beginners Questions & Answers

Sourcing file from parent directory bash

"Debian 9 64x - LXDE" I try to source a file from my parent directory: #!/bin/bash #source.bash . ../links.bash but i get "file not found". I tried . "../links.bash" and . '../links.bash'. I got on all methods the same result. If i use the absolute path it works, but i don't want to... (4 Replies)
Discussion started by: int3g3r
4 Replies

10. UNIX for Beginners Questions & Answers

Unsure why access time on a directory change isn't changing

Hello... And thanks in advance for any help anyone can offer me I was trying to work out the differences between displaying modify, access, and change times with the 'ls' command. Everything seems in order when I look at files, but the access time on a directory doesn't seem to change when I... (4 Replies)
Discussion started by: bodisha
4 Replies
gnome-desktop-item-edit(1)					   User Commands					gnome-desktop-item-edit(1)

NAME
gnome-desktop-item-edit - GNOME Desktop file editor SYNOPSIS
gnome-desktop-item-edit [--create-new] filename DESCRIPTION
gnome-desktop-item-edit is the GNOME Desktop file editor, which you can use to create or edit the .desktop (known as desktop) file. GNOME uses a standard desktop file specification as proposed by freedesktop.org. A desktop file consists of a number of name-value pairs that define how a desktop should organize a particular application. As this is defined as an open standard, integration of applications into GNOME Desktop is relatively straightforward. A basic entry in the desktop file must start with a tag called [Desktop Entry]. It can then have a number of name-value pairs as defined by the standard. The minimum entries are as follows: Name the name of the application Comment a textual description of the application which is displayed as a tooltip message by gnome-panel. When set appropri- ately, the comment can be localized within the same file. Exec the name of the actual executable Icon the file name of the icon image Type the desktop file type Categories a multi-string field which is used by gnome-panel to group applications into the appropriate categories. These desktop files provide the information to gnome-panel, which places the application in the appropriate locations on the panel. In a similar manner, the GNOME file manager (Nautilus) uses information from the desktop files to display the 'applications:///' view. OPTIONS
The following options are supported: --create-new Creates a new .desktop file. OPERANDS
The following operands are supported: filename The name of the desktop file to be edited or viewed. EXAMPLES
Example 1: Editing an existing .desktop file example% gnome-desktop-item-edit fullpath/filename This command invokes the launcher dialog and loads the contents of the specified desktop file into the relevant fields. EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/gnome-desktop-iExecutable for GNOME Desktop file editor /usr/share/applications/Desktopofile ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-panel | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
gnome-panel(1), nautilus(1) Latest version of the GNOME Desktop User Guide for your platform. NOTES
Written by Ghee Teo, Sun Microsystems Inc., 2003. SunOS 5.10 2 Oct 2003 gnome-desktop-item-edit(1)
All times are GMT -4. The time now is 05:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy