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
fverify(8)						      System Manager's Manual							fverify(8)

Name
       fverify - verify software subsets

Syntax
       fverify [-yn]

Description
       The  command  reads  subset  inventory  records	from standard input and verifies that the attributes for the files on the system match the
       attributes listed in the corresponding records.	Invoking with no arguments causes it to report errors to the standard  output  and  prompt
       the user for confirmation before making corrections.

       Missing	files and inconsistencies in file size, checksum, user id, group id, mode, and file type are reported.	If inconsistencies in user
       id, group id or mode are detected the user is asked if they are to be corrected. If a missing file is a directory, it will be created.  All
       errors and informational messages are logged to the file

       The utility uses when installing subsets to guarantee correct installation.

Options
       Specifying both options will cause the -y option to be ignored.

       -n     Error reporting only. When specified, reports errors and does not perform any fixes.

       -y     Fixes  only. When specified, fixes modes, UIDs and GIDs on any files which have incorrect values for these attributes. No user input
	      is required.

Restrictions
       Problems with file size, file type, and file checksum cannot be corrected.

       Because the subset inventories give file names as relative paths, run in the root directory to which the software is installed.

       Many of the files on the system cannot be read or modified without appropriate privilege. Attempting to run without  appropriate  privilege
       may result in an excess of access errors being reported.

Examples
       To use to report verification problems with the BASE subset on ULTRIX, Version 4.0 (VAX), use the following command:
       % cd /
       % /etc/stl/fverify -n </usr/etc/subsets/ULTBASE400.inv

       To correct all problems with the same subset without being presented any prompts or diagnostic output, type:
       % cd /
       % /etc/stl/fverify -y < /usr/etc/subsets/ULTBASE400.inv

       To  interactively  repair  verification	problems with the COMM subset on ULTRIX, Version 4.0 (RISC), use the fverify command with no argu-
       ments:
       % cd /
       % /etc/stl/fverify < /usr/etc/subsets/UDTCOMM400.inv

Diagnostics
       fverify: out of memory
       Not enough memory is available from the system.

       pathname: cannot stat (error-message)
       The file pathname is listed in the inventory but is not on the system.  The error-message explains why.

       pathname: file type `x' should be `y'
       The file is listed in the inventory as being of type `y', but the copy of the file on the disk is type `x'.  The file type codes are:

	      b  block device files
	      c  character device files
	      d  directory files
	      f  regular files
	      l  hard links
	      p  fifos (named pipes)
	      s  symbolic links

       pathname: checksum n should be m
       There is a checksum error on pathname.  The values n and m are the actual and expected values.

       pathname: size n should be m
       The size of file pathname is not as expected. The numbers n and m are the actual and expected values.

       pathname: gid n should be m
       The group id for pathname is not as expected. The group ids n and m are the actual and expected values.

       pathname: uid n should be m
       The user id for pathname is not as expected. The user ids n and m are the actual and expected values.

       pathname: permissions string1 should be string2
       The permissions for pathname are not as expected.  String1 and string2 are the actual and expected permissions. The format of  string1  and
       string2 is the same as that used by the command.

       Creating directory pathname
       The  directory  pathname  is listed in the input inventory but does not exist on the system.  The command will attempt to create the direc-
       tory.

       cannot correct pathname (error-message)
       A problem reported with pathname could not be corrected. The error-message explains why.

       pathname corrected
       A problem with pathname was successfully corrected.

       Cannot create dir pathname (error-message)
       The program could not create a directory it was attempting to create.  The accompanying error-message explains why.

       n verification errors encountered.
       m corrections performed.
       Before exiting, the program prints these statistics describing what had been done.

       The exit status from is the total number of errors detected minus the total number of successful fixes.

Files
       Subset inventory files

       Log File

See Also
       ls(1), stl_inv(5), setld(8)
       Guide to Preparing Software for Distribution on ULTRIX Systems

																	fverify(8)
All times are GMT -4. The time now is 01:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy