Sponsored Content
Top Forums Shell Programming and Scripting Inserting variable values in filename Post 302776939 by CAch on Thursday 7th of March 2013 06:28:49 AM
Old 03-07-2013
Inserting variable values in filename

Hi All,

I have a directory containing multiple files.
and also a txt file which contains the list of all filenames and certain values.

I want to read the text file line by line and if its 2nd column is matched with the filename in directory, then it must insert the values in 7th column to the filename.

ex: DIR [ a.txt
b.txt
c.txt]

filenamelist.txt
Code:
assa  dsad werr vdss a.txt is 2.4
assa  dsad werr vdss b.txt is 3.2
assa  dsad werr vdss c.txt is 4.3

result required in DIR :
Code:
a_2.4
b_3.2
c_4.3


Last edited by Scrutinizer; 03-07-2013 at 07:48 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inserting Values From A File Into A Table

Guys, I want to insert some values from a log file into a temporary table. the values in the log file looks like this SV_NAME CC_NAME CP_DISP_RUN_STATE ------- ------------------- ----------------- sble01 ALLTEL WorkMon24Hrs Running I want to enter the... (2 Replies)
Discussion started by: ragha81
2 Replies

2. Shell Programming and Scripting

help in inserting values in date format

how to assign values in this date format a=`date +"%H%M%S"` how to give value of H=22,here in this format so that i can grep 22nd hour.Below is the script -------------------------------------------------------------------------- a=`date +"%H%M%S"` for i in *.log do cat $i | grep $a... (3 Replies)
Discussion started by: ali560045
3 Replies

3. Shell Programming and Scripting

Inserting variable value into filename

Greetings, people of UNIX/Linux forums. I am having a problem with a script, where I am trying to create a new variable. The value of this variable would be dependent on the value in a couple other previous variables (all variables are 2-digit integers). Here is my code: #set the stations... (3 Replies)
Discussion started by: TheSMan5
3 Replies

4. Shell Programming and Scripting

inserting a variable to a new line

In my script I am using sed to insert a line. Suppose I have a variable called ck_size=5 and a temporary file called tmp I want to add a certain line in the tmp file .Please see the below command sed -i '2a\maitee is $ck_size' /dun/homes/lrsprod/tmp I want in 2 line of tmp file... (7 Replies)
Discussion started by: maitree
7 Replies

5. Shell Programming and Scripting

modify a file by inserting a conditional values

Hi, input file CCCC 1204 215764.85 9405410.40 1189 DDDD 4498 1503 4617 1507 4723 1517 4829 1528 4996 1540 DDDD 5199 1556 5278 1567 5529 1603 5674 1614 6076 1915 DDDD 6605 2371 7004 2779 CCCC ... (4 Replies)
Discussion started by: Indra2011
4 Replies

6. Shell Programming and Scripting

Inserting filename at the top of file

Hi Forum members, I want to insert the filename at the top of file (i.e, first row only) My file name is like asdf_432 And I want to insert this filename in first row as filename is asdf with serial no. 432 Thanks in advance. :) (4 Replies)
Discussion started by: CAch
4 Replies

7. Shell Programming and Scripting

Problem in inserting values of variable of shell

hi all, i have one shell script like this #!/bin/bash -xv ENV_NAME=`cat $IB_HOME_DIR/cfg/ibProfile.sh | grep "RDM_CONN" | cut -f 2 -d "@"` CURRENT_DIR=`pwd`; string=$IB_HOME_DIR string1="$string/FRGFOLDER/input" #sed "s/string3/$string1" frg_event_src.sql > modifiedinsert.sql sqlplus... (2 Replies)
Discussion started by: ramsavi
2 Replies

8. UNIX for Dummies Questions & Answers

Inserting a variable in awk script

I have file input.txt: >TX1-1 Freq 55 cattctgatgaatatttgtcctttagttgttatttgt >TX1-2 Freq 19 cattctgatgaatatttgtcctttagttgttatttgt >TX1-3 Freq 17 cattctgatgaatatttgtcctttagttgttatttgt >TX1-4 Freq 6 cattctgatgaatatttgtcctttagttgttatttgt >TX1-5 Freq 6 cattctgatgaatatttgtcctttagttgttatttgt ... (5 Replies)
Discussion started by: Xterra
5 Replies

9. Shell Programming and Scripting

Inserting values into database from an excel

Hi, I have a requirement where I have an excel sheet with the below values COL1 COL2 COL3 Germany URGENT NORMAL I want to cut the values of this excel in such a way that I get the values and pass it to an insert statement update tbfin set... (2 Replies)
Discussion started by: venkidhadha
2 Replies

10. Shell Programming and Scripting

Inserting values to database

hi , I'm new to Unix shell scripting. I need help to insert read csv which has two columns -emp no and logged date. csv file is a large file so i want to keep the insertion query in a separate .sql file. csv file looks this: empno | loggeddate ___________________ 5666 ,... (5 Replies)
Discussion started by: preema
5 Replies
ZENITY(1)						      General Commands Manual							 ZENITY(1)

NAME
zenity - display GTK+ dialogs SYNOPSIS
zenity [options] DESCRIPTION
zenity is a program that will display GTK+ dialogs, and return (either in the return code, or on standard output) the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts. For example, zenity --question will return either 0 or 1, depending on whether the user pressed OK or Cancel. zenity --entry will output on standard output what the user typed into the text entry field. Comprehensive documentation is available in the GNOME Help Browser, under GNOME/Utilities. OPTIONS
This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). Dialog options --calendar Display calendar dialog --entry Display text entry dialog --error Display error dialog --file-selection Display file selection dialog --info Display info dialog --list Display list dialog --notification Display notification icon --progress Display progress indication dialog --question Display question dialog --text-info Display text information dialog --warning Display warning dialog --scale Display scale dialog General options --title=TITLE Set the dialog title --window-icon=ICONPATH Set the window icon --width=WIDTH Set the dialog width --height=HEIGHT Set the dialog height --timeout=TIMEOUT Set the dialog timeout Calendar options --text=STRING Set the dialog text --day=INT Set the calendar day --month=INT Set the calendar month --year=INT Set the calendar year --date-format=PATTERN Set the format for the returned date Text entry options --text=STRING Set the dialog text --entry-text=STRING Set the entry text --hide-text Hide the entry text Error options --text=STRING Set the dialog text --no-wrap Do not enable text wrapping File selection options --filename=FILENAME Set the filename --multiple Allow selection of multiple filenames in file selection dialog --directory Activate directory-only selection --save Activate save mode --separator=SEPARATOR Specify separator character when returning multiple filenames --confirm-overwrite Confirm file selection if filename already exists Info options --text=STRING Set the dialog text --no-wrap Do not enable text wrapping List options --text=STRING Set the dialog text --column=STRING Set the column header --checklist Use check boxes for first column --radiolist Use radio buttons for first column --separator=STRING Set output separator character --multiple Allow multiple rows to be selected --editable Allow changes to text --print-column=NUMBER Specify what column to print to standard output. The default is to return the first column. 'ALL' may be used to print all columns. --hide-column=NUMBER Hide a specific column Notification options --text=STRING Set the notification text --listen Listen for commands on stdin Progress options --text=STRING Set the dialog text --percentage=INT Set initial percentage --auto-close Close dialog when 100% has been reached --auto-kill Kill parent process if cancel button is pressed --pulsate Pulsate progress bar Question options --text=STRING Set the dialog text --no-wrap Do not enable text wrapping Text options --filename=FILENAME Open file --editable Allow changes to text Warning options --text=STRING Set the dialog text --no-wrap Do not enable text wrapping Scale options --text=STRING Set the dialog text --value=VALUE Set initial value --min-value=VALUE Set minimum value --max-value=VALUE Set maximum value --step=VALUE Set step size --print-partial Print partial values --hide-value Hide value Miscellaneous options -?, --help Show summary of options. --about Display an about dialog. --version Show version of program. Also the standard GTK+ options are accepted. ENVIRONMENT
Normally, zenity detects the terminal window from which it was launched and keeps itself above that window. This behavior can be disabled by unsetting the WINDOWID environment variable. EXAMPLES
Display a file selector with the title Select a file to remove. The file selected is returned on standard output. zenity --title="Select a file to remove" --file-selection Display a text entry dialog with the title Select Host and the text Select the host you would like to flood-ping. The entered text is returned on standard output. zenity --title "Select Host" --entry --text "Select the host you would like to flood-ping" Display a dialog, asking Microsoft Windows has been found! Would you like to remove it?. The return code will be 0 (true in shell) if OK is selected, and 1 (false) if Cancel is selected. zenity --question --title "Alert" --text "Microsoft Windows has been found! Would you like to remove it?" Show the search results in a list dialog with the title Search Results and the text Finding all header files.... find . -name '*.h' | zenity --list --title "Search Results" --text "Finding all header files.." --column "Files" Show an icon in the notification area zenity --notification --window-icon=update.png --text "System update necessary!" Display a weekly shopping list in a check list dialog with Apples and Oranges pre selected zenity --list --checklist --column "Buy" --column "Item" TRUE Apples TRUE Oranges FALSE Pears FALSE Toothpaste Display a progress dialog while searching for all the postscript files in your home directory find $HOME -name '*.ps' | zenity --progress --pulsate AUTHOR
Zenity was written by Glynn Foster <glynn.foster@sun.com>. This manual page was written by Ross Burton <ross@burtonini.com>. SEE ALSO
gdialog(1), dialog(1) February 1st, 2003 ZENITY(1)
All times are GMT -4. The time now is 03:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy