Search Results

Search: Posts Made By: ambijat
7,288
Posted By SriniShoo
If you want to verify before running the code,...
If you want to verify before running the code, comment the mv part and include echo "{j}"
for i in *.pdf
do
FNAME=${i%.*}
EXTN=${i##*.}
BNAME=$(tr -dc '[:alnum:]' <<<${FNAME})
...
7,288
Posted By RavinderSingh13
Hello Ambijat, Please find attached the...
Hello Ambijat,

Please find attached the example for removing the punctuations in lines.


echo "A~\`\!@BCDEFGH" | sed 's/[[:punct:]]//g'


Output will be as follows. You can take...
7,288
Posted By Scrutinizer
Hi, those are parameter expansions...
Hi, those are parameter expansions (https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html).
7,288
Posted By Scrutinizer
You do not need arrays, nor do you need external...
You do not need arrays, nor do you need external programs. You could also try:
#!/bin/bash
for file in *.pdf
do
tofile=${file//[[:punct:]]/_}
tofile=${tofile%_pdf}.pdf
mv "$file"...
7,288
Posted By RavinderSingh13
Hello ambijat, Untested but you can try awk...
Hello ambijat,

Untested but you can try awk also for same.


echo ${a[i]} | awk '{gsub(/[[:punct:]]/,X,$0); gsub("pdf",".pdf",$0);print $0}'



Thanks,
R. Singh
22,362
Posted By Don Cragun
Note that the original request was to delete...
Note that the original request was to delete punctuation characters except for a chosen list of punctuation characters to be exempted. This script will also remove whitespace and control characters....
22,362
Posted By ctsgnb
You can just use the [:space:] character class...
You can just use the [:space:] character class like :

sed 's/[^'$a'[:space:][:alnum:]]*//g' myfileOr if you want keep the space and remove they other type of space you can just :

sed 's/[^'$a'...
22,362
Posted By ctsgnb
Yup, should be possible, just a little example : ...
Yup, should be possible, just a little example :

# cat myfile
Bb2$£¤µ%§\°~`!@#$%^&*()_-+={[}]|:;"'<,>.?/
# a="@#+="
# sed 's/[^'$a'[:alnum:]]*//g' myfile
Bb2µ@#+=
#

# a="#@|_%"
# sed...
22,362
Posted By ctsgnb
Why not to use alnum instead of punct ? Just...
Why not to use alnum instead of punct ?
Just add in the list the character or class you want to keep (like @ and # ) :

# cat myfile
Bb2$£¤µ%§\°~`!@#$%^&*()_-+={[}]|:;"'<,>.?/
# sed...
22,362
Posted By RudiC
If you consider using my proposal above, you can...
If you consider using my proposal above, you can add any number of punctuation chars to be saved from removal. There may be some extra efforts needed to implement using a variable, but it should be...
22,362
Posted By pamu
try sth like this,, sed -e...
try sth like this,,

sed -e 's/#/LOLOLOL/g;s/@/MOMOMO/g;s/\([[:punct:]]\)//g;s/LOLOLOL/#/g;s/MOMOMO/@/g;' file
22,362
Posted By RudiC
Fiddling around with awks, sed, locales, and char...
Fiddling around with awks, sed, locales, and char classes I've come up with this, respecting locale's punctuation class, and allowing to keep any number of punct. chars:sed "s#[]\
$(
...
22,362
Posted By Don Cragun
I must not understand what you're proposing to do...
I must not understand what you're proposing to do here. If you start with a file that contains the punctuation characters comma and period (that you want to keep) and other punctuation characters...
22,362
Posted By Don Cragun
Try changing: cat ${a[$j]} | sed -e...
Try changing:
cat ${a[$j]} | sed -e 's/\([[:punct:]]\)//g' > revised.txtto:
sed -e 's/#/^g/g;s/\([[:punct:]]\)//g;s/^g/#/g' "${a[$j]}" > revised.txtwhere the ^g in both cases is a control character...
5,290
Posted By Corona688
Put them in exclude.txt and use grep -f -F. ...
Put them in exclude.txt and use grep -f -F.

for FILE in *.txt
do
sed 's/[^a-zA-Z \r\t]//g' "$FILE" |
tr -s ' \r\t' '\n' |
grep -v -F -f exclude.txt |...
5,290
Posted By Corona688
I get this. $ ./fator.sh 1 2 3 4 1 2 3 4 No...
I get this. $ ./fator.sh 1 2 3 4
1 2 3 4
No of arguments: 4
length of array is: 4
k[0] = 1
a[0] =
k[1] = 2
a[1] = 2
k[2] = 3
a[2] =
k[3] = 4
a[3] =

$ What am I supposed to be seeing...
5,290
Posted By Corona688
I'd go about that in a slightly different way. ...
I'd go about that in a slightly different way.

1) Strip out all non-alphanumeric and whitespace characters
2) Change all whitespace into newlines
3) Sort
4) uniq -c
5) Sort again to get the...
5,290
Posted By RudiC
You can't use for [[ ... ]], can you? The...
You can't use for [[ ... ]], can you? The requestor should use if / while [[ ... ]] to run the conditional branch.
5,290
Posted By Corona688
It means what it says. (( )) brackets are used...
It means what it says. (( )) brackets are used for arithmetic expressions. If you want to do things like comparing strings, use [[ ]].

[[ ${a[$i]} != "frn2c" ]]
5,290
Posted By Chubler_XL
Your problem was here: a=("${a[$i]}" "$(fator...
Your problem was here:
a=("${a[$i]}" "$(fator ${k[$i]})")

Should be a=(${a[@]} "$(fator ${k[$i]})") ... or why not a[i]=$(fator ${k[i]})

Here is a bit of a cleanup to use bash expressions...
Showing results 1 to 20 of 20

 
All times are GMT -4. The time now is 02:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy