Sponsored Content
Top Forums Shell Programming and Scripting Need to remove first and last character using sed Post 303037574 by wisecracker on Tuesday 6th of August 2019 11:06:08 AM
Old 08-06-2019
POSIX shell, 'sh', compliant:-

Longhand using OSX 10.14.3, default bash terminal:
Code:
Last login: Tue Aug  6 15:56:39 on ttys000
AMIGA:amiga~> echo ',001E:001F,,,02EE,0FED:0FEF,' > /tmp/text
AMIGA:amiga~> text=$( cat /tmp/text )
AMIGA:amiga~> text=${text#?}; text=${text%?}
AMIGA:amiga~> echo "${text}"
001E:001F,,,02EE,0FED:0FEF
AMIGA:amiga~> _

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed to remove character ['

I have a huge file where the each column has data in the format: . I want to remove the from each value. How do I do it with sed? thanks (2 Replies)
Discussion started by: manishabh
2 Replies

2. Shell Programming and Scripting

sed: remove first character from particular line

Hello Experts, I have a file "tt.txt" which is like: #a1=a2 b1=b2 #c1=c2 I need to remove the pound (#) sign from a particular line. In this case let us assume it's 3rd line : "#c1=c2" I can do it through: sed "s/#c1=c2/c1=c2/" tt.txtbut it is possible that I may not know the value... (6 Replies)
Discussion started by: hkansal
6 Replies

3. Shell Programming and Scripting

How to remove space in sed for / character

Hi... i need a script to remove the space before and after the operator like( / ). Ex : Input file apple / manago mango / fresh apple / fresh Desired output: apple/manago mango/fresh apple/fresh Note: betwee the desired operator space should be removed, between words do not remove... (3 Replies)
Discussion started by: vasanth_vadalur
3 Replies

4. Shell Programming and Scripting

Sed is doing my head in! How do you remove the first character of a string?

Hello! Please bare with me, I'm a total newbie to scripting. Here's the sudo code of what I'm trying to do: Get file name Does file exist? If true get length of file name get network id (this will be the last 3 numbers of the file name) loop x 2 If... (1 Reply)
Discussion started by: KatieV
1 Replies

5. Shell Programming and Scripting

any savant ? using AWK/SED to remove newline character between two strings : conditional removal

I'd like to remove (do a pattern or precise replacement - this I can handle in SED using Regex ) ---AFTER THE 1ST Occurrence ( i.e. on the 2nd occurrence - from the 2nd to fourth occurance ) of a specific string : type 1 -- After the 1st occurrence of 1 string1 till the 1st occurrence of... (4 Replies)
Discussion started by: sieger007
4 Replies

6. Shell Programming and Scripting

Need to remove a character using sed

Hi All, I have output like this below ldprod/03 ldprod/02 ldprod/01 ldprod/00 ldnprod/ ldnprod/030 I want only remove all character including / ldprod ldprod ldprod ldprod ldprod ldnprod (8 Replies)
Discussion started by: ranjancom2000
8 Replies

7. Shell Programming and Scripting

Want to remove / and character using awk or sed

Below i am trying to remove "/" and "r" from the output, so i need output as: hdiskpower3 hdisk0 hdisk1 #inq | grep 5773 | awk '{print $1}' | sed 's/dev//g' | awk -F"/" '{$1=$1}1' .....................................................//rhdiskpower0 //rhdiskpower1 //rhdiskpower2... (3 Replies)
Discussion started by: aix_admin_007
3 Replies

8. Shell Programming and Scripting

Remove last occurrence of character (_) and rest of the string in UNIX (sed)

Hi I need help on this ..!! Input : xx_abc_regA xx_def_regB xx_qwe_regC Now i required the output as the below abc def qwe Need to remove last occurrence of character (_) and rest of the string in Unix (sed). Thanks in Advance ..!!! -Nallachand (3 Replies)
Discussion started by: Nallachand
3 Replies

9. Shell Programming and Scripting

sed - remove begin of line up to the third and including occurence of character

hello. How to remove all characters in a line from first character ( a $ ) until and including the third occurrence of that character ( $ ). Any help is welcome. (10 Replies)
Discussion started by: jcdole
10 Replies

10. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies
fixman(1M)																fixman(1M)

NAME
fixman - fix manpages for faster viewing with man command SYNOPSIS
alt-path] DESCRIPTION
The command is a shell script that processes manpages in the directories to unexpand spaces to tabs where possible, and to remove all char- acter-backspace pairs (which usually exist to cause overstriking or underscoring for printer output). Removal of unnecessary character sequences improves the speed of man(1), and reduces disk space consumption. The command should be run after using to create formatted, manpages from unformatted, source files (see catman(1M)). By default, searches for subdirectories in the following parent directories in the order indicated: o o o If the environment variable is set, the directory paths specified by are searched instead of the default. See environ(5) for a description of the environment variable. The command does not remove duplicate blank lines. Thus, all files remain a multiple of one page (66 lines) long and can still be passed directly to (see lp(1)). (Note that man(1) normally uses to accomplish this removal.) To ensure success, should be run by a user who has appropriate privileges. It will take awhile to complete depending on system speed, load, memory size, etc. As a side-effect, file ownerships and permissions may be changed. Options Perform actions based on the given alternate root. With this option, alt-path will be prepended to all directory paths, including default paths or the paths defined by EXTERNAL INFLUENCES
Environment Variables if set, defines the directories to be searched for manpages. WARNINGS
If the value of is not the same while is running as it was when was run or when manpage files were installed, some files may be missed and not processed (see catman(1M)). EXAMPLES
Run fixman from a server to fix the manpages on a diskless under the alternate root This will fix manpages in directories under: FILES
Directories containing [compressed] nroff(1)-formatted versions of manpages AUTHOR was developed by HP. SEE ALSO
catman(1M), chmod(1), expand(1), lp(1), man(1), mv(1), sed(1), environ(5). fixman(1M)
All times are GMT -4. The time now is 10:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy