Sponsored Content
Top Forums Shell Programming and Scripting Bash script - $(ls expr) return double file name with one finishing with '.' Post 302718643 by jcdole on Saturday 20th of October 2012 10:20:47 AM
Old 10-20-2012
Bash script - $(ls expr) return double file name with one finishing with '.'

Hello.

This small part of my script

Code:
#!/bin/bash
SRCDIR=/root/.kde4/share/config
for MY_FILE in  $(ls $SRCDIR/kate*) ; do
    echo "$MY_FILE"
done

give :
Quote:
/root/.kde4/share/config/katepartpluginsrc
/root/.kde4/share/config/katepartpluginsrc.
/root/.kde4/share/config/katepartscriptrc
/root/.kde4/share/config/katepartscriptrc.
/root/.kde4/share/config/katerc
/root/.kde4/share/config/katerc.
/root/.kde4/share/config/kateschemarc
/root/.kde4/share/config/kateschemarc.
/root/.kde4/share/config/katesyntaxhighlightingrc
/root/.kde4/share/config/katesyntaxhighlightingrc.
So for the moment I have modified my script like this :
Code:
#!/bin/bash
SRCDIR=/root/.kde4/share/config
for MY_FILE in  $(ls $SRCDIR/kate*) ; do
    if [[ "$MY_FILE" == $SRCDIR/kate* ]] ; then
        if [[ "$MY_FILE" == $SRCDIR/kate*. ]] ; then
            echo .
        else
            echo "Keep this : $MY_FILE"
        fi
    fi
done

which give
Quote:
Keep this : /root/.kde4/share/config/katepartpluginsrc
.
Keep this : /root/.kde4/share/config/katepartscriptrc
.
Keep this : /root/.kde4/share/config/katerc
.
Keep this : /root/.kde4/share/config/kateschemarc
.
Keep this : /root/.kde4/share/config/katesyntaxhighlightingrc
.
But there is surely a best method.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

help in finishing 2 commands

the first one: 1. i am trying to build a command that searches a text file and outputs the number of words which consists of two 'b' characters in each word separatly like barby (the b characters must be separated from one another) i tried to use grep filepath then i know that we need... (3 Replies)
Discussion started by: newby2
3 Replies

2. Shell Programming and Scripting

Return to HTML file from shell script

Hi! I'm writing a simple script which I call on using a simple html button. The script also recives a simple argument. After the script is done I immediately want to return to my html page. But I dont know how to do that! #!/bin/sh echo "Content-type: text/html" echo "" if then echo... (1 Reply)
Discussion started by: crille
1 Replies

3. Shell Programming and Scripting

How to enter a return key in bash script?

Hi, I'm porting an install script from AIX to Red Hat (2.6.18-164.el5 #1 SMP) I have this script working in both AIX and HP-UX. The script is a wrapper for a Micro Focus Server Express install program. It responds to the install program questions with a here-now list. Responses includes... (14 Replies)
Discussion started by: duker61
14 Replies

4. Shell Programming and Scripting

Script to return first x characters from file

I need a script to read the first 1000 characters of a text file regardless of how many lines it will span. So if my first line has 2000 characters i only want the first 1000 from this line, if my first and second lines have 500 character each then i want all the characters from both lines and... (5 Replies)
Discussion started by: kelseyh
5 Replies

5. Shell Programming and Scripting

Nested double quotes won't work in my bash script?

In a bash script I have: LSCMD="find /project/media/ -mindepth 2 -maxdepth 2 -name \"files*pkg\"" ALL_PACKAGES=$( $LSCMD | sort 2>/dev/null) But I get nothing returned. It's just all blank. If I run the find command in a terminal, I get dozens of hits. I figure it's the way how I'm... (3 Replies)
Discussion started by: superbbrr
3 Replies

6. Shell Programming and Scripting

Getting error in bash script; expr $a + 1: integer expression expected

Hi, I am new to shell/bash script. I am trying to run below script #!/bin/bash a=0 b=10 if then echo "a is equal to be" else echo "a is not equal to be" fi MAX=10 while do echo $a a='expr $a + 1' done (1 Reply)
Discussion started by: Mallikgm
1 Replies

7. Shell Programming and Scripting

Need help in finishing a bash script for listing subfolder by size in a large folder

Greetings everyone. I have seen that you do wonders here. I have a large folder on a Ubuntu linux. Organization main folder, inside 20 000 subfolders, and inside those subolders many other like 5-6 folders and files. I am interested to create an output to a txt file under the bash... (2 Replies)
Discussion started by: ultimo
2 Replies

8. Shell Programming and Scripting

Need output of script on screen and file with correct return status of the called script.

Hi, I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed. Below is my sample... (14 Replies)
Discussion started by: Prathmesh
14 Replies

9. Shell Programming and Scripting

Return: can only `return' from a function or sourced script

Not sure where the problem is. I can run the script without any issue using the following command. . /opt/app/scripts/cdc_migration.sh But it fails with the below error when I try it this way /opt/app/scripts/cdc_migration.sh /opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies
ncursesw5-config(1)					      General Commands Manual					       ncursesw5-config(1)

NAME
ncursesw5-config - helper script for ncurses libraries SYNOPSIS
ncursesw5-config [options] DESCRIPTION
This is a shell script which simplifies configuring applications against a particular set of ncurses libraries. OPTIONS
--prefix echos the package-prefix of ncurses --exec-prefix echos the executable-prefix of ncurses --cflags echos the C compiler flags needed to compile with ncurses --libs echos the libraries needed to link with ncurses --version echos the release+patchdate version of ncurses --abi-version echos the ABI version of ncurses --mouse-version echos the mouse-interface version of ncurses --bindir echos the directory containing ncurses programs --datadir echos the directory containing ncurses data --includedir echos the directory containing ncurses header files --libdir echos the directory containing ncurses libraries --mandir echos the directory containing ncurses manpages --terminfo echos the $TERMINFO terminfo database path, e.g., /usr/share/terminfo --terminfo-dirs echos the $TERMINFO_DIRS directory list, e.g., /etc/terminfo:/usr/share/terminfo --termpath echos the $TERMPATH termcap list, if support for termcap is configured. --help prints this message SEE ALSO
curses(3X) This describes ncurses version 5.9 (patch 20130511). ncursesw5-config(1)
All times are GMT -4. The time now is 05:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy