Sponsored Content
Top Forums Shell Programming and Scripting [Solved] How to increment and add variable length numbers to a variable in a loop? Post 302771007 by joeyg on Tuesday 19th of February 2013 09:42:19 AM
Old 02-19-2013
Hard to even guess at a solution without seeing a sample of the text file.
Please include a sample of the file, and remember to enclose it in CodeTags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies

2. Shell Programming and Scripting

the given code goes in infinite loop and does not increment variable i

code is as #!/bin/sh i=1; while do welcome $i times; i='expr $i+1'; done exit 0; (6 Replies)
Discussion started by: mrityunjay22
6 Replies

3. Shell Programming and Scripting

how to add Loop number to variable name?

Hi there, I need to add a sequence of numbers to existing variables within the script to be able to call the variable automatically. Somehow it's just printing the loop number. Here's what I've got so far. :eek: #!/bin/sh FOLDER1=foo FOLDER2=bar FOLDER3=beer for ((a=1; a <= 3 ; a++))... (2 Replies)
Discussion started by: siul0_0
2 Replies

4. Shell Programming and Scripting

Make variable length record a fixed length

Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types: (H)eader Records (D)etail Records (T)railer Records The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies

5. Shell Programming and Scripting

Increment of a variable

Hi All, I have a variable n that stores a number. Eg. echo $n comes out to be 120. I need to print 121 using echo command on n. Please advice. Thanks in advance !! (4 Replies)
Discussion started by: learning_skills
4 Replies

6. Shell Programming and Scripting

Split variable length and variable format CSV file

Dear all, I have basic knowledge of Unix script and her I am trying to process variable length and variable format CSV file. The file length will depend on the numbers of Earnings/Deductions/Direct Deposits. And The format will depend on whether it is Earnings/Deductions or Direct Deposits... (2 Replies)
Discussion started by: chechun
2 Replies

7. Shell Programming and Scripting

changing a variable length text to a fixed length

Hi, Can anyone help with a effective solution ? I need to change a variable length text field (between 1 - 18 characters) to a fixed length text of 18 characters with the unused portion, at the end, filled with spaces. The text field is actually field 10 of a .csv file however I could cut... (7 Replies)
Discussion started by: dc18
7 Replies

8. Shell Programming and Scripting

[Solved] Assigning a value to a variable name then running a loop on these values

Hi, I was wondering if anyone could assist me for (what is probably) a very straightforward answer. I have input files containing something like File 1 Apples Apples Apples Apples File 2 Bananas Bananas Bananas Bananas (4 Replies)
Discussion started by: hubleo
4 Replies

9. Shell Programming and Scripting

[SOLVED] UNIX FOR loop to read a variable with multiple values

Hi, I have a variable which stores file names as a result of find command. I need to delete all these files one by one, i.e. by a loop. Can anyone tell me how can it be done? The variable f2d has the file names like these abc.txt bcd.txt fff.txt gef.txt Now I have used a loop as... (12 Replies)
Discussion started by: jhilmil
12 Replies

10. Shell Programming and Scripting

Convert variable length record to fixed length

Hi Team, I have an issue to split the file which is having special chracter(German Char) using awk command. I have a different length records in a file. I am separating the files based on the length using awk command. The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 Replies
DD(1)							      General Commands Manual							     DD(1)

NAME
dd - convert and copy a file SYNOPSIS
dd [ option value ] ... DESCRIPTION
Dd copies the specified input file to the specified output with possible conversions. The standard input and output are used by default. The input and output block size may be specified to take advantage of raw physical I/O. The options are -if f Open file f for input. -of f Open file f for output. -ibs n Set input block size to n bytes (default 512). -obs n Set output block size (default 512). -bs n Set both input and output block size, superseding ibs and obs. If no conversion is specified, preserve the input block size instead of packing short blocks into the output buffer. This is particularly efficient since no in-core copy need be done. -cbs n Set conversion buffer size. -skip n Skip n input records before copying. -iseek n Seek n records forward on input file before copying. -files n Catenate n input files (useful only for magnetic tape or similar input device). -oseek n Seek n records from beginning of output file before copying. -count n Copy only n input records. -conv ascii Convert EBCDIC to ASCII. ebcdic Convert ASCII to EBCDIC. ibm Like ebcdic but with a slightly different character map. block Convert variable length ASCII records to fixed length. unblock Convert fixed length ASCII records to variable length. lcase Map alphabetics to lower case. ucase Map alphabetics to upper case. swab Swap every pair of bytes. noerror Do not stop processing on an error. sync Pad every input record to ibs bytes. Where sizes are specified, a number of bytes is expected. A number may end with or to specify multiplication by 1024 or 512 respectively; a pair of numbers may be separated by to indicate a product. Multiple conversions may be specified in the style: is used only if or conversion is specified. In the first two cases, n characters are copied into the conversion buffer, any specified character mapping is done, trailing blanks are trimmed and new-line is added before sending the line to the output. In the latter three cases, characters are read into the conversion buffer and blanks are added to make up an output record of size n. If is unspecified or zero, the and options convert the character set without changing the block structure of the input file; the and options become a simple file copy. SOURCE
/sys/src/cmd/dd.c SEE ALSO
cp(1) DIAGNOSTICS
Dd reports the number of full + partial input and output blocks handled. DD(1)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy