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
quot_hfs(1M)															      quot_hfs(1M)

NAME
quot_hfs: quot - summarize ownership on an HFS file system SYNOPSIS
filesystem ... DESCRIPTION
The command displays the number of 1024-byte blocks in the named HFS filesystem that are currently owned by each user. filesystem is either the name of the directory on which the file system is mounted or the name of the device containing the file system. Options recognizes the following options: Generate a report for all mounted HFS file systems. Report size rather than user statistics. Generates histogram statistics in 3-column format: Column 1: File size in blocks. Sizes are listed in ascending order up to 499 blocks per file. Files occupying 499 or more blocks are counted together on a single line as 499-block files (but column 3 is based on actual number of blocks occupied). Column 2: Number of files of size indicated in column 1. Column 3: Cumulative total blocks occupied by files counted in current plus all preceding lines. Use of this option overrides the and options. Display number of files and space occupied by each user. Specify the file system type Calculate the number of blocks in the file based on file size rather than actual blocks allocated. This option does not account for sparse files (files with holes in them). Accept data from the command (see ncheck(1M)) as input. Run the pipeline: to produce a list of all files and their owners. Report on users. This is the default action. Display three columns containing the number of blocks not accessed in the last 30, 60, and 90 days. Echo the completed command line, but perform no other action. The command line is generated by incorporating the user-specified options and other information derived from This option allows the user to verify the command line. If the options specified are valid, the completed command line is echoed. If the options specified are not valid, an error message is printed. AUTHOR
a disk quota command, was developed by the University of California, Berkeley, Sun Microsystems, Inc., and HP. FILES
Static information about the file systems Mounted file system table Password file (contains user names) SEE ALSO
du(1), find(1), ls(1), fstyp(1M), mount(1M), ncheck(1M), quot(1M), repquota(1M), quota(5). quot_hfs(1M)
All times are GMT -4. The time now is 12:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy