Sponsored Content
Top Forums Shell Programming and Scripting Preserve byte size of fields while pasting it to other file in unix Post 302375873 by dashing201 on Monday 30th of November 2009 02:32:52 AM
Old 11-30-2009
Preserve byte size of fields while pasting it to other file in unix

Preserve byte size of fields while pasting it to other file
Hello
I want to set two fields in a text file to be of size 20.
how to do it using unix ?
eg: ABC.txt

Name | City

I want Name and City both to be of size 20.

Also If I am pasting it in other file the byte size should be preserved.i.e. If I want to append content of ABC.txt to other PQR.txt,
I shall use
paste -d'|' PQR.txt ABC.txt > tmp.tmp

Now
file tmp.tmp should reflect my ABC file content of size 20 each.

Seeking quick suggestions ...
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

2. Shell Programming and Scripting

Getting required fields from a text file in UNIX

My data is something like as shown below. Out of this i want the details of alarms (ex: 1947147711,1947147081......) and the fields( ex :sw=tacmwafabb9:shelf=1:slot=5-2:pport=2) Once i have these details separated, i want the count of these excluding the duplicates. What is the best possible way... (7 Replies)
Discussion started by: rdhanek
7 Replies

3. UNIX for Dummies Questions & Answers

Preserve byte size of fields while pasting it to other file

Hello I want to set two fields in a text file to be of size 20. how to do it using unix ? eg: ABC.txt Name | City I want Name and City both to be of size 20. Also If I am pasting it in other file the byte size should be preserved.i.e. If I want to append content of ABC.txt to other... (0 Replies)
Discussion started by: dashing201
0 Replies

4. Shell Programming and Scripting

pasting fields from two files into one

i have two files with contents file a 1234,abcf 2345,drft 4444,befr file b tom,3 sam,5 dog,7 i want to print first column of file b and join to file a and get output as below tom,1234,abcf sam,2345,drft dog,4444,befr (2 Replies)
Discussion started by: dealerso
2 Replies

5. Shell Programming and Scripting

Calculate byte size of string

Hi, I have task to merge multiple XML's to one big XML. In doing this i have to calculate the byte size of each XML which i will be recieving as a string from a code and append all the recieved XML's to single file. The reason being the byte size and the offset will help me to extract only... (7 Replies)
Discussion started by: chetan.c
7 Replies

6. Shell Programming and Scripting

How to preserve spaces in input fields with awk?

I'm trying to do something pretty simple but its appears more complicated than expected... I've lines in a text file, separated by the comma and that I want to output to another file, without the first field. Input file: file1,item, 12345678 file2,item, 12345678 file2,item, ... (8 Replies)
Discussion started by: Armoric
8 Replies

7. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

8. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
MYSQLI_DATA_SEEK(3)							 1						       MYSQLI_DATA_SEEK(3)

mysqli_result::data_seek - Adjusts the result pointer to an arbitrary row in the result

       Object oriented style

SYNOPSIS
bool mysqli_result::data_seek (int $offset) DESCRIPTION
Procedural style bool mysqli_data_seek (mysqli_result $result, int $offset) The mysqli_data_seek(3) function seeks to an arbitrary result pointer specified by the $offset in the result set. PARAMETERS
o $ result -Procedural style only: A result set identifier returned by mysqli_query(3), mysqli_store_result(3) or mysqli_use_result(3). o $offset - The field offset. Must be between zero and the total number of rows minus one (0..mysqli_num_rows(3) - 1). RETURN VALUES
Returns TRUE on success or FALSE on failure. NOTES
Note This function can only be used with buffered results attained from the use of the mysqli_store_result(3) or mysqli_query(3) func- tions. EXAMPLES
Example #1 Object oriented style <?php /* Open a connection */ $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER BY Name"; if ($result = $mysqli->query($query)) { /* seek to row no. 400 */ $result->data_seek(399); /* fetch row */ $row = $result->fetch_row(); printf ("City: %s Countrycode: %s ", $row[0], $row[1]); /* free result set*/ $result->close(); } /* close connection */ $mysqli->close(); ?> Example #2 Procedural style <?php /* Open a connection */ $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (!$link) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER BY Name"; if ($result = mysqli_query($link, $query)) { /* seek to row no. 400 */ mysqli_data_seek($result, 399); /* fetch row */ $row = mysqli_fetch_row($result); printf ("City: %s Countrycode: %s ", $row[0], $row[1]); /* free result set*/ mysqli_free_result($result); } /* close connection */ mysqli_close($link); ?> The above examples will output: City: Benin City Countrycode: NGA SEE ALSO
mysqli_store_result(3), mysqli_fetch_row(3), mysqli_fetch_array(3), mysqli_fetch_assoc(3), mysqli_fetch_object(3), mysqli_query(3), mysqli_num_rows(3). PHP Documentation Group MYSQLI_DATA_SEEK(3)
All times are GMT -4. The time now is 09:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy