02-26-2014
Quote:
Originally Posted by
Paarth
This may help
echo '12#abcd!@' | sed 's/[0-9]*//g'
Hi Paarth,
I am getting
#abcd!@
i want to remove special characters too
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
How would I get rid of lines having something else than numbers (such as tabs,white space, special characters, empty line, letters).
So I have big file with numers as follows:
12345678901
23456789012
32343678901
42345638901
52345678901
and I sometimes the file might contain some... (2 Replies)
Discussion started by: Juha
2 Replies
2. Shell Programming and Scripting
Hi all,
I have a bunch of files that are named like 12543, 467249877, etc all over some directories.These files are named only with numbers, they dont have any letters or special characters in their file names. Could you please help me out and give me some command/script to remove only those... (6 Replies)
Discussion started by: praveen_indramo
6 Replies
3. Shell Programming and Scripting
Hi all,
Can I edit this script:
find . -type f | while read i;do && mv "$i" "${i//abc/}" ;done
so that it will not only take out abc from the filename but also take out any numbers that might be in the filename as well.
An example would be,
Input:
filename abc 2009.mov
Output:... (7 Replies)
Discussion started by: Monkey Dean
7 Replies
4. Shell Programming and Scripting
How can I remove the numeric (1,2,3,4,5,etc.) in front of each line? The file look like this..
1CREATE OR REPLACE pROD (p_sc_id number,
2 p_snap_id number , p_sid number, p_halt varchar2 default 'N', p_a_nm varchar2 )
3 as
4 v_rtn number;
5
6 v_rtn... (3 Replies)
Discussion started by: Beginer0705
3 Replies
5. Shell Programming and Scripting
Hi,
I am trying to cleanup 7 or 10 digits numeric from the file. So for example :
Input :
3M Corporation
3M Inc. 888-356-8765
3M Inc. 356-8765
3M Inc. 3568765
3M Inc. 356-8765
3M 8883568765 Inc.
Output :
3M Corporation
3M Inc. - -
3M Inc. -
3M Inc.
3M Inc. - (8 Replies)
Discussion started by: msalam65
8 Replies
6. Shell Programming and Scripting
lsps -s | awk '{print $1}'|tail -1
71680 MB
lsps -s | awk '{print $2}'|tail -1
2%
vmstat |grep lcpu |awk '{print $3}'
lcpu=8
I need to removt the MB % lcpu= from the outputs so they can show as
71680
2
8
respectively.
Please advise.
Thank you so much, (8 Replies)
Discussion started by: Daniel Gate
8 Replies
7. Shell Programming and Scripting
I have a file that has some text that looks like this
Some Text
1. More text
2. Different text
Final Text
I would like the remove the lines of text that start with the numbers.
Some Text
Final Text
I have tried to use cat file.txt | grep -Ev 1. >... (9 Replies)
Discussion started by: icculus99
9 Replies
8. Shell Programming and Scripting
Hello All,
I was wondering if someone might know how to do this. I have a word list that is format like the example below. I need to take away the :number after that... is there some kind of command I could use to remove them?
123456:5562
password:1507
123456789:989
qwerty:877... (7 Replies)
Discussion started by: 3therk1ll
7 Replies
9. Shell Programming and Scripting
Hi,
I have numerous files which have data in the following format
A|B|123.|Mr.|45.66|33|zz
L|16.|33.45|AC.|45.
I want to remove decimal point only if it is last character in a number.
O/p should be
A|B|123|Mr.|45.66|33|zz
L|16|33.45|AC.|45
I tried this
sed -e 's/.|/|/g'
Problem... (6 Replies)
Discussion started by: wahi80
6 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I am trying to remove trailing zeros from numbers in a csv file.
CSV Input : 0.5000,abc,2.00,2.400,285.850,285a.850,205.180800,mno000,a0b0,2.860
Expected Output :
.5,abc,2,2.4,285.85,285a.850,205.1808,mno000,a0b0,2.86
Can you please help.
Thanks. (11 Replies)
Discussion started by: manubatham20
11 Replies
LEARN ABOUT CENTOS
shell-quote
SHELL-QUOTE(1) User Contributed Perl Documentation SHELL-QUOTE(1)
NAME
shell-quote - quote arguments for safe use, unmodified in a shell command
SYNOPSIS
shell-quote [switch]... arg...
DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands
or files with embedded white space or shell globbing characters safely. Here are a few examples.
EXAMPLES
ssh preserving args
When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and
passes them to "$SHELL -c". This doesn't work as intended:
ssh host touch 'hi there' # fails
It creates 2 files, hi and there. Instead, do this:
cmd=`shell-quote touch 'hi there'`
ssh host "$cmd"
This gives you just 1 file, hi there.
process find output
It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to
split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote:
eval set -- `find -type f -print0 | xargs -0 shell-quote --`
debug shell scripts
shell-quote is better than echo for debugging shell scripts.
debug() {
[ -z "$debug" ] || shell-quote "debug:" "$@"
}
With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can.
save a command for later
shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command
you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are
things the user can't pass through), you can do something like this:
user_switches=
while [ $# != 0 ]
do
case x$1 in
x--pass-through)
[ $# -gt 1 ] || die "need an argument for $1"
user_switches="$user_switches "`shell-quote -- "$2"`
shift;;
# process other switches
esac
shift
done
# later
eval "shell-quote some-command $user_switches my args"
OPTIONS
--debug
Turn debugging on.
--help
Show the usage message and die.
--version
Show the version number and exit.
AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions.
AUTHOR
Roderick Schertler <roderick@argon.org>
perl v5.16.3 2010-06-11 SHELL-QUOTE(1)