Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by xeroxzerox
at 2024-11-28 00:21:50
Point:500 Replies:10 POST_ID:828837USER_ID:11544
Topic:
Linux;;
Hi expert,
Need a linux script for remove the all line which end with /.
accounts/user1/
accounts/user1/pending cn 28.11.11.xls
accounts/user1/DELIVERY/
accounts/user1/DELIVERY/APRIL-12/
accounts/user1/MARCH 12/
accounts/user1/REPORTS/
accounts/user2/WORK.xls
accounts/user2/CONTRACT.xls
It show output like this:
accounts/user1/pending cn 28.11.11.xls
accounts/user2/WORK.xls
accounts/user2/CONTRACT.xls
remove line which end with /
Thanks & Regards,
Xerox
Need a linux script for remove the all line which end with /.
accounts/user1/
accounts/user1/pending cn 28.11.11.xls
accounts/user1/DELIVERY/
accounts/user1/DELIVERY/APRIL-12/
accounts/user1/MARCH 12/
accounts/user1/REPORTS/
accounts/user2/WORK.xls
accounts/user2/CONTRACT.xls
It show output like this:
accounts/user1/pending cn 28.11.11.xls
accounts/user2/WORK.xls
accounts/user2/CONTRACT.xls
remove line which end with /
Thanks & Regards,
Xerox
Assisted Solution
Expert: duncanb7 replied at 2024-11-28 01:57:20
150 points EXCELLENT
please also convert dos to unix format that make sure yourfile in unix format by
dos2unix yourfile.txt output.txt OR on vi editor by :set fileformat=unix and save it
this is my final , please try it , it works at my side
sed 's//$//g' yourfile.txt>output.txt
Or overwrite file
sed -i 's//$//g' yourfile.txt
dos2unix yourfile.txt output.txt OR on vi editor by :set fileformat=unix and save it
this is my final , please try it , it works at my side
sed 's//$//g' yourfile.txt>output.txt
Or overwrite file
sed -i 's//$//g' yourfile.txt
Expert: Dan Craciun replied at 2024-11-28 01:38:33
What sed -i.backup does is:
1. copy 2013-11-28_ad.log as 2013-11-28_ad.log.backup
2. delete lines from 2013-11-28_ad.log as per the regular expressions
If you do NOT want your original file modified, but instead copy the lines that don't end in "/" in another file, try this:
sed -n '//$/!p' ./2013-11-28_ad.log > 2013-11-28_ad.log.new
1. copy 2013-11-28_ad.log as 2013-11-28_ad.log.backup
2. delete lines from 2013-11-28_ad.log as per the regular expressions
If you do NOT want your original file modified, but instead copy the lines that don't end in "/" in another file, try this:
sed -n '//$/!p' ./2013-11-28_ad.log > 2013-11-28_ad.log.new
Author: xeroxzerox replied at 2024-11-28 01:21:00
HI duncanb7,
your command output is
root@LEN-A70-198:/home/# tr "// " " " 2013-11-28_ad.log > /home/outout.txt
tr: extra operand `2013-11-28_ad.log'
Try `tr --help' for more information.
Hi DanCraciun,
i do it but it only store 724 lines in orignal file & after, it send all lines in backup file include without / lines.
Why original file contain only 724 lines.if sed read all (30000 lines) then it store all lines.
your command output is
root@LEN-A70-198:/home/# tr "// " " " 2013-11-28_ad.log > /home/outout.txt
tr: extra operand `2013-11-28_ad.log'
Try `tr --help' for more information.
Hi DanCraciun,
i do it but it only store 724 lines in orignal file & after, it send all lines in backup file include without / lines.
Why original file contain only 724 lines.if sed read all (30000 lines) then it store all lines.
Expert: Dan Craciun replied at 2024-11-28 01:04:44
@xeroxzerox: in infile.backup you have your original text. Including all the lines that end in "/".
The cleaned lines are in infile.
The cleaned lines are in infile.
Expert: duncanb7 replied at 2024-11-28 01:02:20
it should works
tr "// " " " <yourfile.txt >outout.txt
it will only replace the last "/" at the end of line
tr "// " " " <yourfile.txt >outout.txt
it will only replace the last "/" at the end of line
Expert: Dan Craciun replied at 2024-11-28 00:50:34
@duncanb7: what does "//" mean?
Expert: duncanb7 replied at 2024-11-28 00:50:28
Could you attach your file in this thread ?
Author: xeroxzerox replied at 2024-11-28 00:48:16
Firstly Thanks for response.and script running great-fully but it move some lines which end without / in backup file.
Expert: duncanb7 replied at 2024-11-28 00:41:55
Linux command :
write it into other new outputfile.txt
sed 's////g' yourfile.txt >outputfie.txt
or
overwrite the same file yourfile.txt after
sed -i 's////g' yourfile.txt
write it into other new outputfile.txt
sed 's////g' yourfile.txt >outputfie.txt
or
overwrite the same file yourfile.txt after
sed -i 's////g' yourfile.txt
Accepted Solution
Expert: Dan Craciun replied at 2024-11-28 00:25:51
350 points EXCELLENT
sed -i.backup '//$/d' ./infile