Working with lines or variables that have spaces or special characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Working with lines or variables that have spaces or special characters
# 1  
Old 12-12-2014
Working with lines or variables that have spaces or special characters

Example:
Code:
while read line
do
stat -c %G $line
done < somefile.txt

The problem is that inside somefile.txt lines can have any symbol allowed as file name, like (). Even with spaces, it splits the words.


somefile.txt:
Code:
dira/my first jump.avi
dirb/surf video (1080p).mkv


Last edited by Tribe; 12-12-2014 at 03:07 PM..
# 2  
Old 12-12-2014
Hi,

Try:
Code:
stat -c %G "$line"

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 12-12-2014
Thanks worked!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing blank/white spaces and special characters

Hello All , 1. I am trying to do a task where I need to remove Blank spaces from my file , I am usingawk '{$1=$1}{print}' file>file1Input :- ;05/12/1990 ;31/03/2014 ; Output:- ;05/12/1990 ;31/03/2014 ;This command is not removing all spaces from... (6 Replies)
Discussion started by: himanshu sood
6 Replies

2. Shell Programming and Scripting

Lines starting with special characters

Hi I have a file and need to extract lines starting with "grep ^" I tried with quotes single/double before/after but no luck. suggestion pls, thanks! (2 Replies)
Discussion started by: magnus29
2 Replies

3. Shell Programming and Scripting

Fetch the lines which contains special characters

Hi All, My source file contains special characters(Latin characters).I need to fetch only the lines which contains the special characters. The problem is i don't know which all latin/special characters can come in the source. Is there anyway to extract the lines which contain letters other... (3 Replies)
Discussion started by: joe!!
3 Replies

4. Shell Programming and Scripting

grep lines having special characters

Hi, I have a file which has numerous lines and some of the lines having special characters in it. i want to grep the lines which are having special characters. say, one line looks like - %*()$#@"", | acbd antoher line looks like ***##^%! | efcg so these kind of lines are present... (5 Replies)
Discussion started by: rbalaj16
5 Replies

5. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

6. UNIX for Advanced & Expert Users

Grep returning partial lines due to special characters

Hey guys, I have a file with an ID which I'm using to grep out the original record from another file. Problem is I have special characters in the original file, and grep is returning only a partial record. How can I get around this? Appreciate your help! Pete (3 Replies)
Discussion started by: peteroc
3 Replies

7. Shell Programming and Scripting

Adding text to file on certain lines with(special characters)

I need to add "new lines" of text with special characters, to specific lines in the file. There are 3 modifications needed. Been testing 2 here without success. #!/usr/bin/perl use FileHandle; $file=FileHandle->new; $FILENAME="/opt/etc/usr/file.txt"; $file->open ("<$FILENAME") or die... (13 Replies)
Discussion started by: A4ron4perl
13 Replies

8. Shell Programming and Scripting

Spaces in Lines for Variables

All, I am driving myself crazy over this one. I have run a find command against a volume on a nas. That returns a full listing of path and file name. This is an example of one line of output. I redirected the output of the find command to a file. ... (4 Replies)
Discussion started by: bubbwe
4 Replies

9. Solaris

removing special characters, white spaces from a field in a file

what my code is doing, it is executing a sql file and the resullset of the query is getting stored in the text file in a fixed format. for that fixed format i have used the following code:: Code: awk -F":"... (2 Replies)
Discussion started by: priyanka3006
2 Replies

10. Shell Programming and Scripting

Grep not working - special characters??

I have a file that I am processing with a while loop from, in come cases the grep/sed command (strings record | grep “errorDetail” | sed 's&*errorDetail\(.*)\(/errorDetail\).*&\1&') works and produces the data I am after and in some it does not. I have inspected the data within the failing... (3 Replies)
Discussion started by: gugs
3 Replies
Login or Register to Ask a Question