Sponsored Content
Top Forums Shell Programming and Scripting How to use sed to replace the a string in the same file using sed? Post 302407990 by alister on Saturday 27th of March 2010 01:31:38 PM
Old 03-27-2010
Unless your filesystem has run out of inodes, there is no advantage nor necessity. I was using the inode number to demonstrate that the file's identity (it's inode/serial number) is changed when sed/perl edits it (even if the name, in the end, is unchanged), in case your request strictly required in-place editing. It did not, therefore most of what I said has no relevance to your situation (though it may still be interesting to know Smilie).

Cheers,
Alister
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do i use sed to replace string with values from a dictionary file

I have file 1 with one million rows. one of the fields is "FIRSTNAME" (the string) I have a second file with about 20 first names. JUDE DAVID HOMER CANE ABEL MARTY CARL SONNY STEVE BERT OSCAR MICKY JAMES JOHN GLENN DOUG (3 Replies)
Discussion started by: yoyolandre
3 Replies

2. Shell Programming and Scripting

Using sed to replace a string in file with a string in a variable that contains spaces

Hi, i call my shell like: my_shell "my project name" my script: #!/bin/bash -vx projectname=$1 sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp cp temp test_config_doxy the following error occurres: sed s/'PROJECT_NAME ... (2 Replies)
Discussion started by: vivelafete
2 Replies

3. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

4. Shell Programming and Scripting

sed replace string in file with stdin

Hi Im trying to do the following: grep -H Date: out/* | sed 's/':'/ /' | awk '$4 ~ /^/ {print $1}' | while read VARIABLE; do awk '{print $1,$3,$2}' $VARIABLE | sed (take stdin and replace a string in $VARIABLE) done What this is basically doing is finding all files with Date: in... (11 Replies)
Discussion started by: duonut
11 Replies

5. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this? e.g: a=$(echo -e wert trewt ertert ertert ertert erttert erterte rterter tertertert ert) How do i replace the STRING with $a? I try this: sed -i 's/STRING/'"$a"'/g' filename.ext but this don' t work (2 Replies)
Discussion started by: jforce
2 Replies

6. Shell Programming and Scripting

How to replace a string containing @ in a file using sed ?

I have a list of names and email addresses. Sample File - username=poga--poga@yahoo.com new-york,US 512834 username=poga123--poga123@hotmail.com new-jersey,US 0894753 Requirement is to replace the email ids as dummy_username@xyz.com using sed only. Output File -... (4 Replies)
Discussion started by: poga
4 Replies

7. Shell Programming and Scripting

How to replace a string with a variable in a file using sed?

I have a file having some text like: PATH_ABC=/user/myLocation I have to replace "/user/myLocation" with a session variable say, $REPLACE_PATH, where $REPLACE_PATH=/user/myReplaceLocation The following sed command is not working. It is writing PATH_ABC=$REPLACE_PATH in the file ... (2 Replies)
Discussion started by: SKhan
2 Replies

8. Shell Programming and Scripting

sed - Replace string with file contents

Hello, I have two files: file1 and file2 file1 has the following info: --- host: "localhost" port: 3000 reporter_type: "zookeeper" zk_hosts: - "localhost:2181" file2 contains an IP address (1.1.1.1) What I want to do is replace localhost with 1.1.1.1, so that the... (4 Replies)
Discussion started by: Jay Kah
4 Replies

9. Shell Programming and Scripting

Replace string in XML file with awk/sed with string from another

Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file: </member> <member> <name>TransactionID</name> <value><string>123456789123456</string></value> </member> <member> <name>Number</name> ... (9 Replies)
Discussion started by: cozzin
9 Replies

10. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
xfs_check(8)						      System Manager's Manual						      xfs_check(8)

NAME
xfs_check - check XFS filesystem consistency SYNOPSIS
xfs_check [ -i ino ] ... [ -b bno ] ... [ -f ] [ -s ] [ -v ] [ -l logdev ] device DESCRIPTION
xfs_check checks whether an XFS filesystem is consistent. It is normally run only when there is reason to believe that the filesystem has a consistency problem. The filesystem to be checked is specified by the device argument, which should be the disk or volume device for the filesystem. Filesystems stored in files can also be checked, using the -f flag. The filesystem should normally be unmounted or read-only during the execution of xfs_check. Otherwise, spurious problems are reported. OPTIONS
-f Specifies that the filesystem image to be processed is stored in a regular file at device (see the mkfs.xfs(8) -d file option). This might happen if an image copy of a filesystem has been made into an ordinary file. -l logdev Specifies the device where the filesystem's external log resides. Only for those filesystems which use an external log. See the mkfs.xfs(8) -l option, and refer to xfs(5) for a detailed description of the XFS log. -s Specifies that only serious errors should be reported. Serious errors are those that make it impossible to find major data struc- tures in the filesystem. This option can be used to cut down the amount of output when there is a serious problem, when the output might make it difficult to see what the real problem is. -v Specifies verbose output; it is impossibly long for a reasonably-sized filesystem. This option is intended for internal use only. -i ino Specifies verbose behavior for the specified inode ino. For instance, it can be used to locate all the blocks associated with a given inode. -b bno Specifies verbose behavior for the specific filesystem block at bno. For instance, it can be used to determine what a specific block is used for. The block number is a "file system block number". Conversion between disk addresses (i.e. addresses reported by xfs_bmap(8)) and file system blocks may be accomplished using xfs_db(8)'s convert command. Any output that is produced when xfs_check is not run in verbose mode indicates that the filesystem has an inconsistency. The filesystem can be repaired using either xfs_repair(8) to fix the filesystem in place, or by using xfsdump(8) and mkfs.xfs(8) to dump the filesystem, make a new filesystem, then use xfsrestore(8) to restore the data onto the new filesystem. Note that xfsdump may fail on a corrupt filesystem. However, if the filesystem is mountable, xfsdump can be used to try and save important data before repairing the filesystem with xfs_repair. If the filesystem is not mountable though, xfs_repair is the only viable option. DIAGNOSTICS
If the filesystem is completely corrupt, a core dump might be produced instead of the message device is not a valid filesystem If the filesystem is very large (has many files) then xfs_check might run out of memory. In this case the message out of memory is printed. The following is a description of the most likely problems and the associated messages. Most of the diagnostics produced are only meaning- ful with an understanding of the structure of the filesystem. agf_freeblks n, counted m in ag a The freeblocks count in the allocation group header for allocation group a doesn't match the number of blocks counted free. agf_longest n, counted m in ag a The longest free extent in the allocation group header for allocation group a doesn't match the longest free extent found in the allocation group. agi_count n, counted m in ag a The allocated inode count in the allocation group header for allocation group a doesn't match the number of inodes counted in the allocation group. agi_freecount n, counted m in ag a The free inode count in the allocation group header for allocation group a doesn't match the number of inodes counted free in the allocation group. block a/b expected inum 0 got i The block number is specified as a pair (allocation group number, block in the allocation group). The block is used multiple times (shared), between multiple inodes. This message usually follows a message of the next type. block a/b expected type unknown got y The block is used multiple times (shared). block a/b type unknown not expected The block is unaccounted for (not in the freelist and not in use). link count mismatch for inode nnn (name xxx), nlink m, counted n The inode has a bad link count (number of references in directories). rtblock b expected inum 0 got i The block is used multiple times (shared), between multiple inodes. This message usually follows a message of the next type. rtblock b expected type unknown got y The real-time block is used multiple times (shared). rtblock b type unknown not expected The real-time block is unaccounted for (not in the freelist and not in use). sb_fdblocks n, counted m The number of free data blocks recorded in the superblock doesn't match the number counted free in the filesystem. sb_frextents n, counted m The number of free real-time extents recorded in the superblock doesn't match the number counted free in the filesystem. sb_icount n, counted m The number of allocated inodes recorded in the superblock doesn't match the number allocated in the filesystem. sb_ifree n, counted m The number of free inodes recorded in the superblock doesn't match the number free in the filesystem. SEE ALSO
mkfs.xfs(8), xfsdump(8), xfsrestore(8), xfs_ncheck(8), xfs_repair(8), xfs(5). xfs_check(8)
All times are GMT -4. The time now is 11:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy