Sponsored Content
Top Forums Shell Programming and Scripting sed to remove 1st two characters every line of text file Post 302252540 by ajp7701 on Wednesday 29th of October 2008 07:18:49 PM
Old 10-29-2008
thank you!

thank you all! I'll probably make a new post, but I actually need the last two characters removed also....
>cat file1.txt
10081551
10081599
10082234
10082259
20081134
20081159
30082232
10087721
>
ends up looking like:
>cat file1.txt
100815
100815
100822
100822
200811
200811
300822
100877
>
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed remove last 10 characters of a line start from 3rd line

hello experts, I need a sed command that remove last 10 characters of a line start from 3rd line. any suggestions? Thanks you (7 Replies)
Discussion started by: minifish
7 Replies

2. Shell Programming and Scripting

sed to remove last 2 characters of txt file

sed 's/^..//' file1.txt > file2.txt this will remove the first two characters of each line of a text file, what sed command will remove the last two characters? This is a similar post to my other....sry if I'm being lazy.... I need a file like this (same as last post) >cat file1.txt 10081551... (1 Reply)
Discussion started by: ajp7701
1 Replies

3. Shell Programming and Scripting

Remove special characters from text file

Hi All, i am trying to remove all special charecters().,/\~!@#%^$*&^_- and others from a tab delimited file. I am using the following code. while read LINE do echo $LINE | tr -d '=;:`"<>,./?!@#$%^&(){}'|tr -d "-"|tr -d "'" | tr -d "_" done < trial.txt > output.txt Problem ... (10 Replies)
Discussion started by: kkb
10 Replies

4. UNIX for Advanced & Expert Users

Sed - add text to start of line if 1st char anything but space

Problem: I have a lot of files, the files first line should always have 4 spaces before any text. Occasionally some of the files will miss the leading spaces and it's a problem. This is only in the first line. So if there are 4 spaces then text, do nothing. If there are not 4 spaces, add 4... (2 Replies)
Discussion started by: Vryali
2 Replies

5. UNIX Desktop Questions & Answers

Remove new line characters from a file

I tried using below command tr -cd "" < InputFile.xml > output.txt ============= This removes all the tabs/newline/extra spaces from a file it successfully removed all the extra spaces,tabs and new line characters but then the complete file become one record. I want to retain one new line... (1 Reply)
Discussion started by: saini
1 Replies

6. Shell Programming and Scripting

Remove all junk characters from a text file

I am using flatfile, in that flat file we are getting the junk chars 1)I21001f<82>^Me<85>!h49 Service Charge 2) I21001f‚ e...!h49 Service Charge please tell me how to remove all junk chars in unix scripts. (1 Reply)
Discussion started by: Talari
1 Replies

7. Shell Programming and Scripting

sed to remove partial text in one line only

I have test.xml XML file like <Report account="123456" start_time="2014-09-08T00:00:00+00:00" end_time="2014-09-10T23:59:59+00:00" user="Dollar Tree" limit="1000000" more_sessions="some text "> <Session ......rest of xml............... I need output like <Report> <Session ......rest of... (3 Replies)
Discussion started by: kumars1331@gmai
3 Replies

8. Shell Programming and Scripting

I want to remove 1st and last two characters of each line of the file

I want to remove 1st and last two characters of each line of the file Ex: file1 zzfile1ee @xfile2:y qfile3>> @ file4yy and redirect to the file called new Basically file will have any charcter including space, spical character... Please help.... (7 Replies)
Discussion started by: shell1509
7 Replies

9. Shell Programming and Scripting

sed to remove text from file

Trying to use sed to, in-place, remove specific text from a file. Since there are / in the text I use | to escape that character. Thank you :). sed -i -e 's|xxxx://www.xxx.com/xx/xx/xxx/.*/|' /home/cmccabe/list sed: -e expression #1, char 51: unterminated `s' command (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

How to remove new line characters from data rows in a Pipe delimited file?

I have a file as below Emp1|FirstName|MiddleName|LastName|Address|Pincode|PhoneNumber 1234|FirstName1|MiddleName2|LastName3| Add1 || ADD2|123|000000000 2345|FirstName2|MiddleName3|LastName4| Add1 || ADD2| 234|000000000 OUTPUT : ... (1 Reply)
Discussion started by: styris
1 Replies
cat(1)							      General Commands Manual							    cat(1)

Name
       cat - concatenate and print data

Syntax
       cat [ -b ] [ -e ] [ -n ] [ -s ] [ -t ] [ -u ] [ -v ] file...

Description
       The  command reads each file in sequence and displays it on the standard output.  Therefore, to display the file on the standard output you
       type:
       cat file
       To concatenate two files and place the result on the third you type:
       cat file1 file2 > file3
       To concatenate two files and append them to a third you type:
       cat file1 file2 >> file3
       If no input file is given, or if a minus sign (-) is encountered as an argument, reads from the standard input file.  Output is buffered in
       1024-byte blocks unless the standard output is a terminal, in which case it is line buffered.  The utility supports the processing of 8-bit
       characters.

Options
       -b   Ignores blank lines and precedes each output line with its line number.

       -e   Displays a dollar sign ($) at the end of each output line.

       -n   Precedes all output lines (including blank lines) with line numbers.

       -s   Squeezes adjacent blank lines from output and single spaces output.

       -t   Displays non-printing characters (including tabs) in output.  In addition to those representations used with the -v  option,  all  tab
	    characters are displayed as ^I.

       -u   Unbuffers output.

       -v   Displays  non-printing  characters (excluding tabs and newline) as the ^x.	If the character is in the range octal 0177 to octal 0241,
	    it is displayed as M-x. The delete character (octal 0177) displays as ^?.  For example, is displayed as ^X.

See Also
       cp(1), ex(1), more(1), pr(1), tail(1)

																	    cat(1)
All times are GMT -4. The time now is 07:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy