Sponsored Content
Top Forums Shell Programming and Scripting Read a file and save every word in a variable to use Post 303033859 by MadeInGermany on Friday 12th of April 2019 03:18:25 PM
Old 04-12-2019
With bash-4 it's a piece of cake:
Code:
#!/bin/bash
# bash-4 required
declare -A sym
sym=(
[zero]=0
[one]=1
[two]=2
[three]=3
[four]=4
[five]=5
[plus]=+
)

while read -r -a words
do
  out=""
  for word in "${words[@]}"
  do
    out+=${sym[$word]-" $word "}
  done
  echo "$out"
done

This User Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read file from within AWK and save $1 to a variable

Hi I am very new to NAWK programming so this question is probably going to sound really stupid: I have a NAWK script which contains a DO loop. During each loop it runs a FORTRAN program which in turn generates two output files , each one containing 2 integer variables. I would appreciate it... (8 Replies)
Discussion started by: robbiegregg
8 Replies

2. Shell Programming and Scripting

Read popup message and save it in file

Hi, I am trying to automate one of the application using IE:Auotmation in perl My web application has few text fields and 2 buttons "Save Changes" and "Discard Changes".I have written code to enter values to the text fields fetching from input file and click the button "Save Changes".As soon as... (0 Replies)
Discussion started by: jyo123.jyothi
0 Replies

3. Shell Programming and Scripting

To read data word by word from given file & storing in variables

File having data in following format : file name : file.txt -------------------- 111111;name1 222222;name2 333333;name3 I want to read this file so that I can split these into two paramaters i.e. 111111 & name1 into two different variables(say value1 & value2). i.e val1=11111 &... (2 Replies)
Discussion started by: sjoshi98
2 Replies

4. Shell Programming and Scripting

Read file and for each line replace two variables, add strings and save output in another file

Hi All, I have a file, let's call it "info.tmp" that contains data like this .. ABC123456 PCX333445 BCD789833 I need to read "info.tmp" and for each line add strings in a way that the final output is put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)' where XXX... (5 Replies)
Discussion started by: Andy_ARG
5 Replies

5. Shell Programming and Scripting

cannot get to read from file and save to file

how can i get this script to read users input from file and save the users input if it is not in the file? #!/bin/sh echo -n "filename:" read filename for i in 1 2 3 4 5 do echo -n "Enter filename:" read lineoftext echo "$lineoftext" >> $filename done (1 Reply)
Discussion started by: noob
1 Replies

6. Shell Programming and Scripting

Read a file name from a text file and save it in a variable

i have a text file consists of different file names like: line 1: lib/libIMb.so message broker file line 2: lil/imbdfg.lil message broker file i need to extract libIMb.so and imbdfg.lil files from those lines and save them in a variable. so that i can search for... (9 Replies)
Discussion started by: santosh2626
9 Replies

7. UNIX for Advanced & Expert Users

How to save a data of a file into a variable?

My requirement is to read a column data from a file & save it in a variable for each row & process it. I am using the below code- Leadlines="$TGTFILE/Error.txt">>$log_file while read line do id = ` echo $line | cut -d "," -f1 ` email = ` echo $line | cut -d "," -f2 ` ----------- done My... (2 Replies)
Discussion started by: saga20
2 Replies

8. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

9. UNIX for Dummies Questions & Answers

To count total of specific character in a file and save its value to a variable

Hi all, I have a file that contains characters. How do I get total of spesific character from that file and save the count to a variable for doing for calculation. data.txt 1 2 2 2 2 3 3 4 5 6 7 8 5 4 3 4 (5 Replies)
Discussion started by: weslyarfan
5 Replies

10. Shell Programming and Scripting

Find a word and increment the number in the word & save into new files

Hi All, I am looking for a perl/awk/sed command to auto-increment the numbers line in file, P1.tcl: run_build_model sparc_ifu_dec run_drc set_faults -model path_delay -atpg_effectiveness -fault_coverage add_delay_paths P1 set_atpg -abort_limit 1000 run_atpg -ndetects 1000 I would like... (6 Replies)
Discussion started by: jypark22
6 Replies
XtCaseProc()															      XtCaseProc()

Name
  XtCaseProc - interface definition for procedure to convert the case of keysyms.

Synopsis
  typedef void (*XtCaseProc) (Display*, KeySym, KeySym *, KeySym *);
	 Display *display
	 KeySym  keysym;
	 KeySym  *lower_return;
	 KeySym  *upper_return;

Inputs
  display     Provides the display connection for which the conversion is required.

  keysym      Specifies the keysym to convert.

Outputs
  lower_return
	      Returns the lowercase equivalent for keysym.

  upper_return
	      Returns the uppercase equivalent for keysym.

Description
  An  XtCaseProc  is a case converter procedure registered with XtRegisterCaseConverter(), and invoked by XtConvertCase() and by the Transla-
  tion Manager in order to obtain the uppercase and lowercase versions of a keysym.  It should store the upper and  lower  case  versions  of
  keysym  at the addresses specified by lower_return and upper_return.	If there is no case distinction, it should store keysym at both loca-
  tions.

Usage
  You should only need to write a case converter procedure if you are working with non-standard keysyms.

Example
  The default case converter from the R4 Intrinsics is as follows:

     /* ARGSUSED */
     void _XtConvertCase(dpy, sym, lower, upper)
	 Display *dpy;
	 KeySym sym;
	 KeySym *lower;
	 KeySym *upper;
     {
	 *lower = sym;
	 *upper = sym;
	 switch(sym >> 8) {
	     case 0:
		 if ((sym >= XK_A) && (sym <= XK_Z))
		     *lower += (XK_a - XK_A);
		 else if ((sym >= XK_a) && (sym <= XK_z))
		     *upper -= (XK_a - XK_A);
		 else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
		     *lower += (XK_agrave - XK_Agrave);
		 else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis))
		     *upper -= (XK_agrave - XK_Agrave);
		 else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn))
		     *lower += (XK_oslash - XK_Ooblique);
		 else if ((sym >= XK_oslash) && (sym <= XK_thorn))
		     *upper -= (XK_oslash - XK_Ooblique);
		 break;
	     default:
		 /* XXX do all other sets */
		 break;
	 }
     }

See Also
  XtConvertCase(1), XtGetKeysymTable(1), XtKeysymToKeycodeList(1), XtRegisterCaseConverter(1), XtSetKeyTranslator(1), XtTranslateKeycode(1).

Xt - Keyboard Handling														      XtCaseProc()
All times are GMT -4. The time now is 05:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy