Sponsored Content
Top Forums Shell Programming and Scripting How i can obtain differents data on a single pass? Post 302598725 by alexscript on Thursday 16th of February 2012 03:41:18 AM
Old 02-16-2012
Code:
#!/bin/bash

function param_val {
    awk "/^${1}=/{gsub(/^${1}="'/,""); print; exit}' $2
}
 
echo "Dynamic {" 
for CF in `ls -c1 /usr/share/applications/*.desktop`
do
    name=$(param_val Name $CF)

    executable=$(param_val Exec $CF)

    icon=$(param_val Icon $CF)

    categories=$(param_val Categories $CF | awk -F ";" '{print $1}')

    echo " Entry = \"$name\" { Actions = \"Exec $executable\" }"

done
echo "}"

I replace:
categories=$(param_val Categories $CF | cut -d\; -f1)
with:
categories=$(param_val Categories $CF | awk -F ";" '{print $1}')
for remove the dependency with the command line cut.

This is the first release with some minor adjustment.

Thanks for the help. Smilie

Last edited by alexscript; 02-17-2012 at 05:25 AM.. Reason: minor correction
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to use cut function to obtain this data out in script?

Hi....can you guys help me out in this script?? Below is a text file script....called Bukom.txt and it contains these: BUKOM 20060101 2.5 2.6 2.7 2.8 2.9 2.3 2.1 BUKOM 20060102 2.4 2.5 2.6 2.7 2.7 2.6 2.4 BUKOM 20060103 2.1 2.3 2.5 2.6 2.7 2.7 2.6 Can you guys help... (2 Replies)
Discussion started by: forevercalz
2 Replies

2. Shell Programming and Scripting

pass curls progress/status data to a file

hello hackers again. please help me out once again. i have a script which executes CURL to fetch a file from the web and instantly outputs the files content to STDOUT. now my question - can i somehow write the progress-status to a file? so that curl acts silently (-s) and only puts... (0 Replies)
Discussion started by: scarfake
0 Replies

3. Web Development

how to pass data in webrick sevelts? please help

Hi all, I am a newbie to servlet programming using webrick... Was wondering how to accept data from a form and do necessary processing.. To start with i wrote a sample servlet that accepts a name and prints "welcome <name>" But I do not know how to take this value from the form into the... (0 Replies)
Discussion started by: wrapster
0 Replies

4. Shell Programming and Scripting

Read Oracle Username password SID from single file and pass it to shell

Dear All I am trying to write one shell which will be running through Cron which contain one SQL query. But I want to draw/fetch the Username password and Instance name (required to loging to the database) from one single file to run that SQL query . Also this file contain details of multiple... (2 Replies)
Discussion started by: jhon
2 Replies

5. Shell Programming and Scripting

How to pass different number of arguments in a single shot

I have one configuration file. The number of lines in the file will vary. I need to pass each line as a parameter to a shell script in a single shot. Ex: Suppose file contains: ou=x,o=z o=y Suppose the shell script name is sample.sh. Then the script should be called like sample.sh ou=x.o=z... (6 Replies)
Discussion started by: saurabhkoar
6 Replies

6. Shell Programming and Scripting

Extract sequences of bytes from binary for differents blocks

Hello to all, I would like to search sequences of bytes inside big binary file. The bin file contains blocks of information, each block begins is estructured as follow: 1- Each block begins with the hex 32 (1 byte) and ends with FF. After the FF of the last block, it follows 33. 2- Next... (59 Replies)
Discussion started by: Ophiuchus
59 Replies

7. Programming

Query SQL get two values differents from the same columns

Hi, I have 2 different values in the same column and two different values in other column Query 1 ins name value 1 Test 12345 1 TestV1 12/10/2014 8 Test 85435 8 TestV1 11/11/2005 9 Test 42232 9 TestV1 19/10/2000 6 Test 54321... (6 Replies)
Discussion started by: faka
6 Replies

8. Shell Programming and Scripting

awk - matching on 2 columns for differents lines

Given this file (I separated them in block to make my explanation clearer): 92157768877;Sof_deme_Fort_Email_am_%yyyy%%mm%%dd%;EMAIL;20/02/2015;1;0;0 92157768877;Sof_trav_Fort_Email_am_%yyyy%%mm%%dd%;EMAIL;20/02/2015;1;0;0 91231838895;Sof_deme_faible_Email_am;EMAIL;26/01/2015;1 0;0... (1 Reply)
Discussion started by: Andy_K
1 Replies

9. Shell Programming and Scripting

Pass some data from csv to xml file using shell/python

Hello gurus, I have a csv file with bunch of datas in each column. (see attached) Now I have an .xml file in the structure of below: ?xml version="1.0" ?> <component id="root" name="root"> <component id="system" name="system"> <param name="number_of_A" value="8"/> ... (5 Replies)
Discussion started by: Zam_1234
5 Replies

10. UNIX for Beginners Questions & Answers

How to pass a single quote to the program?

Dear forum members, My question is simple. I want to pass a single quote (') to be read as belonging as an addition to the letters C1', C2', C3', C4', C5', O1', O2', O3', O4' & O5' to the program voronota query-contacts which would be run through shell script and should print out numerical... (7 Replies)
Discussion started by: Aurimas
7 Replies
DESKTOP-FILE-INSTALL(1) 				      General Commands Manual					   DESKTOP-FILE-INSTALL(1)

NAME
desktop-file-install, desktop-file-edit - Installation and edition of desktop files SYNOPSIS
desktop-file-install [--dir=DIR] [-m MODE|--mode=MODE] [--vendor=VENDOR] [--delete-original] [--rebuild-mime-info-cache] [EDITOPTION]... FILE... desktop-file-edit [EDITOPTION]... FILE DESCRIPTION
The desktop-file-install program is a tool to install, and optionally edit, desktop files. The desktop-file-edit program is a tool to edit a desktop file. They are mostly useful for developers and packagers. Various options are available to edit the desktop files. The edit options can be specified more than once and will be processed in the same order as the options passed to the program. desktop-file-install and desktop-file-edit will always try to validate the resulting desktop file. A failure to validate might lead to the abortion of the installation of the desktop files. The list of registered categories and desktop environments is defined in the Menu specification: http://freedesktop.org/wiki/Specifica- tions/menu-spec. OPTIONS
The following options are supported: --dir=DIR Install desktop files to the DIR directory. -m, --mode=MODE Set the permissions of the destination files to MODE. --vendor=VENDOR Add a vendor prefix to the desktop files. If a file already has this prefix, nothing happens; else, the file will be named VENDOR- FILE. For example: if VENDOR is freedesktop.org and FILE is specification.desktop, the result file will be freedesktop.org-specifi- cation.desktop. --delete-original Delete the source desktop files, leaving only the target files. Effectively "renames" the desktop files. --rebuild-mime-info-cache Rebuild the MIME types application database after installing the desktop files. See update-desktop-database(1) for information about this database. EDIT OPTIONS
The following edit options are supported: --set-key=KEY Set the KEY key to the value passed to the next --set-value option. A matching --set-value option is mandatory. --set-value=VALUE Set the key specified with the previous --set-key option to VALUE. A matching --set-key option is mandatory. --set-name=NAME Set the name (key Name) to NAME. If a name was already set, it will be overridden. Localizations of the old name will be removed. --copy-name-to-generic-name Copy the value of the Name key to the GenericName key. Note that a desktop file requires a Name key to be valid, so this option will always have an effect. --set-generic-name=GENERIC-NAME Set the generic name (key GenericName) to GENERIC-NAME. If a generic name was already set, it will be overridden. Localizations of the old generic name will be removed. --copy-generic-name-to-name Copy the value of the GenericName key to the Name key, if the GenericName key is present. --set-comment=COMMENT Set the comment (key Comment) to COMMENT. If a comment was already set, it will be overridden. Localizations of the old comment will be removed. --set-icon=ICON Set the icon (key Icon) to ICON. If an icon was already set, it will be overridden. Localizations of the old icon will be removed. --add-category=CATEGORY Add CATEGORY to the list of categories (key Categories). If CATEGORY was already present in the list, this operation is a no-op. A non-registered category should be prefixed with X-. --remove-category=CATEGORY Remove CATEGORY from the list of categories (key Categories). If CATEGORY was not present in the list, this operation is a no-op. --add-mime-type=MIME-TYPE Add MIME-TYPE to the list of MIME types (key MimeType). If MIME-TYPE was already present in the list, this operation is a no-op. --remove-mime-type=MIME-TYPE Remove MIME-TYPE from the list of MIME types (key MimeType). If MIME-TYPE was not present in the list, this operation is a no-op. --add-only-show-in=ENVIRONMENT Add ENVIRONMENT to the list of desktop environments where the desktop files should be displayed (key OnlyShowIn). If ENVIRONMENT was already present in the list, this operation is a no-op. A non-registered desktop environment should be prefixed with X-. Note that an empty OnlyShowIn key in a desktop file means that the desktop file will be displayed in all environments. --remove-only-show-in=ENVIRONMENT Remove ENVIRONMENT from the list of desktop environments where the desktop files should be displayed (key OnlyShowIn). If ENVIRON- MENT was not present in the list, this operation is a no-op. --add-not-show-in=ENVIRONMENT Add ENVIRONMENT to the list of desktop environments where the desktop files should not be displayed (key NotShowIn). If ENVIRONMENT was already present in the list, this operation is a no-op. A non-registered desktop environment should be prefixed with X-. Note that an empty NotShowIn key in a desktop file means that the desktop file will be displayed in all environments. --remove-not-show-in=ENVIRONMENT Remove ENVIRONMENT from the list of desktop environments where the desktop files should not be displayed (key NotShowIn). If ENVI- RONMENT was not present in the list, this operation is a no-op. --remove-key=KEY Remove the KEY key from the desktop files, if present. ENVIRONMENT
Some environment variables change the behavior of desktop-file-install: DESKTOP_FILE_VENDOR This variable can be used as an alternative to the --vendor option. If the --vendor option is used, this environment variable will be ignored. DESKTOP_FILE_INSTALL_DIR This variable can be used as an alternative to the --dir option. If the --dir option is used, this environment variable will be ignored. RPM_BUILD_ROOT This variable is set when building RPM packages. If the --dir option and the DESKTOP_FILE_INSTALL_DIR environment variable are not used, it will automatically be prepended to the default install directory to install the desktop files appropriately when building packages. BUGS
If you find bugs in the desktop-file-install program, please report these on https://bugs.freedesktop.org. SEE ALSO
desktop-file-validate(1) update-desktop-database(1) FREEDESKTOP.ORG DESKTOP-FILE-INSTALL(1)
All times are GMT -4. The time now is 05:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy