Sponsored Content
Top Forums Shell Programming and Scripting stripping certain characters in at the middle of a string Post 302194109 by era on Monday 12th of May 2008 08:39:48 AM
Old 05-12-2008
Really not at all clear what you are getting at, but try this.

Code:
vnix$ IFS='|@'
vnix$ read stuff into variables
see@hear|touch@smell
vnix$ echo $stuff
see
vnix$ echo $into
hear
vnix$ echo $variables
touch smell

The | is not a very suitable separator, otherwise you could also use set -- to split this into multiple tokens.
 

10 More Discussions You Might Find Interesting

1. Programming

how to insert and delete characters in the middle of file

I have a problem that I want to insert and delete some chars in the middle of a file. fopen() and fdopen() just allow to append at the end. Is there any simple method or existing library that allow these actions? Thanks in advance.:confused: (7 Replies)
Discussion started by: ivancheung
7 Replies

2. UNIX for Dummies Questions & Answers

Stripping a portion of string from behind!!!

Hi, How to strip a portion of a file name from behind...Say for Eg..i have a file name like aaaaa.bbbbb.Mar-17-2007 i want to remove .Mar-17-2007...is there a one line command which can give this output... Thanks Kumar (5 Replies)
Discussion started by: kumarsaravana_s
5 Replies

3. Shell Programming and Scripting

stripping leftmost characters from string

Hi there, if i have some strings ie test_324423 test_242332 test_767667 but I only want the number part (the bolded bit) how do I strip the leftmost 5 characters from the output so that i will have just 324423 242332 767667 any help would be greatly appreciated Gary (5 Replies)
Discussion started by: hcclnoodles
5 Replies

4. Shell Programming and Scripting

Stripping the spaces in a string variable

Hi , i have to strip the spaces in the string which has the following value ABC DEF i want this to appear like this ABC DEF is there any spilt method? please help.... Thanks (3 Replies)
Discussion started by: rag84dec
3 Replies

5. Shell Programming and Scripting

Bash script - stripping away characters that can't be used in filenames

I want to create a temp file which is named based on a search string. The search string may contain spaces or characters that aren't supposed to be used in filenames so I want to strip those out. My thought was to use 'tr' with but the result is the opposite of what I want: $ echo "test... (5 Replies)
Discussion started by: mglenney
5 Replies

6. UNIX for Dummies Questions & Answers

sed replacing in vi, / characters in the middle

I tried to replace the following in vi: old: 'e/thesis/pp/zones/zones' new: 'd/so162/fix/pp' For that, I used: :%s/e/thesis/pp/zones/zones/d/so162/fix/pp/g but doesn't work, a trailing character error message appeared. How can I get it? Thanks in advance (3 Replies)
Discussion started by: Gery
3 Replies

7. Shell Programming and Scripting

Stripping characters from a variable

I'm using a shell script to get user input with this command: read UserInput I would then like to take the "UserInput" variable and strip out all of the following characters, regardless of where they appear in the variable or how many occurrences there are: \/":|<>+=;,?*@ I'm not sure... (5 Replies)
Discussion started by: nrogers64
5 Replies

8. Shell Programming and Scripting

stripping out digits from a string with sed

i want to parse a string and only display the digits in that string... How would i accomplish this with sed command. For example. input string: " 033434343 dafasdf" output string: 03343434 Thanks (2 Replies)
Discussion started by: timmylita
2 Replies

9. Shell Programming and Scripting

Stripping characters from a file and reformatting according to another one

Dear experts, my problem is pretty tricky. I want to change a file (see attached input.txt), according to another file (help.txt). The output that is desired is in output.txt. The example is attached. Note that -dashes should not be treated specially, they are considered normal characters,... (2 Replies)
Discussion started by: TheTransporter
2 Replies

10. Shell Programming and Scripting

Stripping unwanted characters in field

I wrote myself a small little shell script to clean up a file I have issues with. In particular, I am stripping down a fully qualified host/domain name to just the hostname itself. The script works, but from a performance standpoint, it's not very fast and I will be working with large data sets. ... (4 Replies)
Discussion started by: dagamier
4 Replies
STAT(3) 								 1								   STAT(3)

stat - Gives information about a file

SYNOPSIS
array stat (string $filename) DESCRIPTION
Gathers the statistics of the file named by $filename. If $filename is a symbolic link, statistics are from the file itself, not the sym- link. lstat(3) is identical to stat(3) except it would instead be based off the symlinks status. PARAMETERS
o $filename - Path to the file. RETURN VALUES
stat(3) and fstat(3) result format +--------+--------------------------------------+---+ |Numeric | | | | | | | | | Associative | | | | | | | | Description | | | | | | +--------+--------------------------------------+---+ | 0 | | | | | | | | | dev | | | | | | | | device number | | | | | | | 1 | | | | | | | | | ino | | | | | | | | inode number * | | | | | | | 2 | | | | | | | | | mode | | | | | | | | inode protection mode | | | | | | | 3 | | | | | | | | | nlink | | | | | | | | number of links | | | | | | | 4 | | | | | | | | | uid | | | | | | | | userid of owner * | | | | | | | 5 | | | | | | | | | gid | | | | | | | | groupid of owner * | | | | | | | 6 | | | | | | | | | rdev | | | | | | | | device type, if inode device | | | | | | | 7 | | | | | | | | | size | | | | | | | | size in bytes | | | | | | | 8 | | | | | | | | | atime | | | | | | | | time of last access (Unix timestamp) | | | | | | | 9 | | | | | | | | | mtime | | | | | | | | time of last modification (Unix | | | | timestamp) | | | | | | | 10 | | | | | | | | | ctime | | | | | | | | time of last inode change (Unix | | | | timestamp) | | | | | | | 11 | | | | | | | | | blksize | | | | | | | | blocksize of filesystem IO ** | | | | | | | 12 | | | | | | | | | blocks | | | | | | | | number of 512-byte blocks allocated | | | | ** | | | | | | +--------+--------------------------------------+---+ * On Windows this will always be 0. ** Only valid on systems supporting the st_blksize type - other systems (e.g. Windows) return -1. In case of error, stat(3) returns FALSE. Note Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB. ERRORS
/EXCEPTIONS Upon failure, an E_WARNING is emitted. EXAMPLES
Example #1 stat(3) example <?php /* Get file stat */ $stat = stat('C:phpphp.exe'); /* * Print file access time, this is the same * as calling fileatime() */ echo 'Access time: ' . $stat['atime']; /* * Print file modification time, this is the * same as calling filemtime() */ echo 'Modification time: ' . $stat['mtime']; /* Print the device number */ echo 'Device number: ' . $stat['dev']; ?> Example #2 Using stat(3) information together with touch(3) <?php /* Get file stat */ $stat = stat('C:phpphp.exe'); /* Did we failed to get stat information? */ if (!$stat) { echo 'stat() call failed...'; } else { /* * We want the access time to be 1 week * after the current access time. */ $atime = $stat['atime'] + 604800; /* Touch the file */ if (!touch('some_file.txt', time(), $atime)) { echo 'Failed to touch file...'; } else { echo 'touch() returned success...'; } } ?> NOTES
Note Note that time resolution may differ from one file system to another. Note The results of this function are cached. See clearstatcache(3) for more details. Tip As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to "Supported Protocols and Wrappers" to determine which wrappers support stat(3) family of functionality. SEE ALSO
lstat(3), fstat(3), filemtime(3), filegroup(3). PHP Documentation Group STAT(3)
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy