Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to insert a string and variable at specified position in command in bash? Post 303042168 by rbatte1 on Tuesday 17th of December 2019 07:35:10 AM
Old 12-17-2019
From my suggestion in post 5, I'm sure you can attempt to replace the sub-process on line 2 (the bit between $( and )) such that the output it creates uses a loop based on a counter to create the required number of rows, but then, however would would handle it if one of the files didn't exist?

Please give us the actual problem you are trying to solve, with the actual conditional, the actual logic and the actual files listed in the actual directory and we might actually be able to help you. Otherwise we're just guessing at what you need help with.





Thanks, in advance,
Robin
These 2 Users Gave Thanks to rbatte1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to find a position and print some string in the next and same position

I need a script for... how to find a position of column data and print some string in the next line and same position position should find based on *HEADER8* in text for ex: ord123 abs 123 987HEADER89 test234 ord124 abc 124 987HEADER88 test235 ... (1 Reply)
Discussion started by: naveenkcl
1 Replies

2. Shell Programming and Scripting

search a line and insert string into specific at position

Hi, guys. I have one question: How can I search for a line with certain string in it and then insert a string into this line? For example: There is a file called shadow, the contents of it are below: ************************** ... yuanz:VIRADxMsadfDF/Q:0:0:50:7:::... (9 Replies)
Discussion started by: daikeyang
9 Replies

3. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

4. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

5. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

6. Shell Programming and Scripting

Insert charactera in 1st position of specific lines using vi editor or sed command

Dear all, i am having text file like below surya rama ranga laxman rajesh reddy i want add string (OK) before a text from line 3 to 5 the result will be surya rama OK ranga OK laxman OK rajesh reddy (1 Reply)
Discussion started by: suryanarayana
1 Replies

7. Shell Programming and Scripting

Need command or script to print all lines from 2nd position to last but one position

hi guys, i want command or script to display the content of file from 2nd position to last but one position of a file abcdefghdasdasdsd 123,345,678,345,323 434,656,656,656,656 678,878,878,989,545 4565656667,65656 i want to display the same above file without first and... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

8. Shell Programming and Scripting

Search for a string at a particular position and replace with blank based on position

Hi, I have a file with multiple lines(fixed width dat file). I want to search for '02' in the positions 45-46 and if available, in that lines, I need to replace value in position 359 with blank. As I am new to unix, I am not able to figure out how to do this. Can you please help me to achieve... (9 Replies)
Discussion started by: Pradhikshan
9 Replies

9. UNIX for Beginners Questions & Answers

Bash: Insert in a variable a file

hi all i have a problem in the bash shell. i'd like insert in a variable a file for example : i have a file datafine.log in this file there is : 17/JUN/2019 i want to insert the value of datafine.log in a variable. Regards Frncesco edit by bakunin: please use CODE-tags for your data... (2 Replies)
Discussion started by: Francesco_IT
2 Replies

10. UNIX for Beginners Questions & Answers

How to insert subnode in xml file using xmlstarlet or any other bash command?

I have multiple xml files where i want to update a subnode if the subnode project points to different project or insert a subnode if it doesn't exist using a xmlstarlet or any other command that can be used in a bash script. I have been able to update the subnode project if it doesn't point to... (1 Reply)
Discussion started by: Sekhar419
1 Replies
locale(1)						      General Commands Manual							 locale(1)

NAME
locale - get locale-specific (NLS) information SYNOPSIS
name ... DESCRIPTION
The command displays information about the current locale or about available locales. When invoked without arguments, displays the name and actual or implied value of each of the locale-related environment variables in the order shown below, one per line: An actual value is the value the variable actually has in the user's environment. An implied value is derived from the value of another variable. Implied values are displayed enclosed in double quotes, while actual values are unquoted. The determination of implied values is that if the variable is present and has a non-null value, that is the actual value for and all of the other variables take its value as an implied value. If is not set, all of the variables that are set are shown with their value as an actual value. Any that have no value are shown with the value of the environment variable as their implied value. is displayed as if it has no value. If is set to NULL or to an invalid string, all of the variables are set to the default "C" locale. The value of has precedence over any one of the environment variables and If environment variables are not defined, provides the default. See catopen(3C) for more details. The command can take multiple arguments, which may be locale category names, locale keywords, or the special word (see localedef(1M) for a description of locale keywords and charmaps). If an argument is a keyword, the value associated with that keyword in the current environ- ment is displayed and possibly other information, depending on selected options. If an argument is a category name (i.e., the values of all keywords defined in that category are displayed. If an argument is the special word the charmap file (if any) that was used in the definition of the current locale is displayed. Non-printable characters are printed as hexadecimal values in the form, except that if a different escape character has been defined for the locale, it is displayed instead of the "". Options The following options are available: List all available locales. These are the possible meaningful values that can be assigned to or any of the variables on the system. They are depen- dent upon which locales have been installed on the system. By default on a PA-RISC system, the locales in are listed. By default on an Itanium(R)-based system, the locales in are listed. This option takes 32 (for ILP32, 32-bit int, long, pointer, 32-bit offset) or 64 (for LP64, 64-bit long, pointer, 64-bit offset) as its argument. Display 32-bit locales for PA-RISC and Itanium-based systems. Display 32-bit locales for PA-RISC and Itanium-based systems. Display only 64-bit locales on 64-bit systems. If executed on a 32-bit system, an error message is returned. List Itanium-based system 32-bit locales, Itanium-based system 64-bit locales, PA-RISC 32-bit locales and PA-RISC 64-bit locales available on the system. Display a list of available charmap files on the system. See localedef(1M) for a definition of charmap files and their usage. Display names of locale categories that have been selected either explicitly or by giving a keyword contained therein. This option may be used with the option. Display names of keywords that have been selected either explicitly or by providing their containing category as an argument. Keyword names and values are displayed as: <keyword>=<value> Without the option, only the values are displayed. This option can be used with the option. Display 32-bit PA-RISC locales. (Option available only on Itanium-based systems.) Display 64-bit PA-RISC locales. (Option available only on Itanium-based systems.) name Specify the locale category name, locale keyword, or the special word EXTERNAL INFLUENCES
Environment Variables provides a default value for the internationalization variables that are unset or null. If is unset or null, the default value of "C" (see lang(5)) is used. If any of the internationalization variables contains an invalid setting, will behave as if all internationalization variables are set to "C". See environ(5). when set to a non-empty string value, overrides the values of all other internationalization variables. determines the interpretation of text as single and/or multi-byte characters, the classification of characters as printable, and the char- acters matched by character class expressions in regular expressions. determines the locale that should be used to affect the format and content of diagnostic messages written to standard error, and informa- tive messages written to standard output. determines the location of message catalog for the processing of International Code Set Support Single- and multi-byte character code sets are supported. RETURN VALUE
The command exits with one of the following values: All requested information was found and displayed successfully. An error occurred in either finding or displaying the information. EXAMPLES
If the locale environment variables are set as: the command: gives the following output: The command: produces: If is set to and no other locale variables are set, the command: produces: which correspond to the keywords decimal_point, thousands_sep, grouping, and alt_digit. SEE ALSO
localedef(1M), catopen(3C), localeconv(3C), nl_langinfo(3C), setlocale(3C), charmap(4), localedef(4), environ(5), lang(5). STANDARDS CONFORMANCE
locale(1)
All times are GMT -4. The time now is 01:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy