' for reading (No such file or directory)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ' for reading (No such file or directory)
# 1  
Old 07-26-2015
' for reading (No such file or directory)

Code:
1.1 Solaris 10 8/07 s10s_u4wos_12b SPARC
1.2 Patch: 127714-03 Obsoletes: Requires: 120011-14 Incompatibles: Packages: SUNWsshcu, SUNWsshdu, SUNWsshu Patch: 128253-01 Obsoletes: Requires: Incompatibles: Packages: SUNWsshcu Patch: 126630-01 Obsoletes: Requires: Incompatibles: Packages: SUNWtcsh
1.3
1.3.1

Code:
echo '1.1;'  
grep '1.1 ' 1.txt | awk '{print substr($0,index($0," ")+1)}'
echo '1.2;' 
grep '1.2' 1.txt | awk '{print substr($0,index($0," ")+1)}' 
echo '1.3;' 
grep '1.3 ' 1.txt | awk '{print substr($0,index($0," ")+1)}'
echo '1.3.1;' 
grep '1.3.1 ' 1.txt | awk '{print substr($0,index($0," ")+1)}'

Code:
1.1;
Solaris 10 8/07 s10s_u4wos_12b SPARC
1.2;
' for reading (No such file or directory)
1.3;
1.3.1;

I should not have the ' for reading (No such file or directory). I tried it standalone and it manage to work.
Code:
grep '1.2' 1.txt | awk '{print substr($0,index($0," ")+1)}'
Patch: 127714-03 Obsoletes: Requires: 120011-14 Incompatibles: Packages: SUNWsshcu, SUNWsshdu, SUNWsshu Patch: 128253-01 Obsoletes: Requires: Incompatibles: Packages: SUNWsshcu Patch: 126630-01 Obsoletes: Requires: Incompatibles: Packages: SUNWtcsh

---------- Post updated at 02:26 AM ---------- Previous update was at 02:13 AM ----------

Hi, I applied a dos2unix it manage to work already. Thanks.
This User Gave Thanks to alvinoo For This Post:
# 2  
Old 07-26-2015
The following would seem to be a MUCH more efficient way to do that:
Code:
awk '{	if(sub(/ /, ";\n")) print
	else print $0 ";"
}' 1.txt

If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk.
# 3  
Old 07-26-2015
Code:
 perl -pe 's/^((\d\.?)+)[\n ]/$1;\n/' 1.txt

# 4  
Old 07-26-2015
So much thanks.

It works.

Code:
1.1;
Solaris 10 8/07 s10s_u4wos_12b SPARC
1.2;
Patch: 127714-03 Obsoletes: Requires: 120011-14 Incompatibles: Packages: SUNWsshcu, SUNWsshdu, SUNWsshu Patch: 128253-01 Obsoletes: Requires: Incompatibles: Packages: SUNWsshcu Patch: 126630-01 Obsoletes: Requires: Incompatibles: Packages: SUNWtcsh
1.3;
1.3.1;

Will it be possible to check if the first word is 1.2 1.3 or 1.3.1 any number that has a decimal place

Last edited by alvinoo; 07-27-2015 at 06:32 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Reading a file from a different directory in a Bash script

Hi all, Given here under a section of a script I am using. SIMDIR="/home/Ins/forces" cd $SIMDIR for file in `ls *.forces` do basename=`echo $file | sed 's/\.*$//'` extname=`echo $file | sed 's/*\(*\)\.\(.*\)/\2\1/'` echo "Processing file: "$basename python convert.py... (4 Replies)
Discussion started by: Theo Score
4 Replies

2. Shell Programming and Scripting

Help with reading directory paths with spaces from a file

Hi I want to know how to handle the spaces in the below scenario. I have a file (CON_zip_path_1.txt) which has some directory paths with spaces in directory names . My requirement is to unzip these zip files to another path. Please see the code below and the error. CON_zip_path_1.txt... (4 Replies)
Discussion started by: paul1234
4 Replies

3. Shell Programming and Scripting

' for reading (No such file or directory) `Solaris_websummary.txt

echo "1.1 Apply latest OS patches;" awk '/1.2 Install/ {P=0} P {print $0} FNR==1{printf("From file %s:\n", FILENAME)} /1.1 Apply/ {P=1}' solarisappsummary.txt solarisdbsummary.txt solaris_websummary.txt echo "1.2 Install TCP Wrappers;" awk '/1.3 Install/ {P=0} P {print $0}... (1 Reply)
Discussion started by: alvinoo
1 Replies

4. UNIX for Dummies Questions & Answers

Reading the dates from a file & moving the files from a directory

Hi All, I am coding for a requirement where I need to read a file & get the values of SUB_DATE. Once the dates are found, i need to move the files based on these dates from one directory to another. ie, this is how it will be in the file, SUB_DATE = 20120608,20120607,20120606,20120606... (5 Replies)
Discussion started by: dsfreddie
5 Replies

5. Shell Programming and Scripting

fatal: cannot open file `TNAME' for reading (No such file or directory)

Hi, I am running this command through a shell script and getting the error mentioned in the subject line: testing.awk -f x.txt TNAME My testing.awk file contains something like ++++++++++++++++++ #!/usr/bin/awk -f BEGIN{ TAB_NAME="INSERT_ONE_" ARGV ; } if ( $1=="JAM_ONE" &&... (1 Reply)
Discussion started by: kunwar
1 Replies

6. Shell Programming and Scripting

reading files from a directory.

Can some body help me to code this? go to a specific directory.(/home/abcd/test) file1.txt, file2.txt, ... .. filen.txt read the files in side the folder 'test' and print the content of each file into other folder in the same directory lets say(testresult) with the same file name... (4 Replies)
Discussion started by: rocking77
4 Replies

7. Shell Programming and Scripting

Reading from Directory

I am trying to make a simple script where you type in a directory, and the script tells you how many directories are within the directory, how many files, and some other general file information. My problem is setting up a for loop to read the info about the files inside the specified directory.... (2 Replies)
Discussion started by: ajw08f
2 Replies

8. UNIX for Dummies Questions & Answers

Reading filename from directory

I am using the following code to read filename from the directory: for i in ` ls $inputDir | grep $partialName*.csv` do echo $i done But the echo is giving me the following: ls | grep cm_ctx*.csv instead of the full filename "cm_ctx_2009_07_15_17_18.csv" Any ideas anyone? I... (2 Replies)
Discussion started by: khanvader
2 Replies

9. Shell Programming and Scripting

Reading files in directory

Hi Everyone , have a nice day i need a help on this thing algo is something like in certain path like /root/user1 i have many files , i need a code which could open every file one by one and then each file has contents like this <moid>CcnCounters=CAPv3-Received-Total-Requests, Source =... (3 Replies)
Discussion started by: Dastard
3 Replies

10. UNIX for Dummies Questions & Answers

reading directory for most recent file?

Dear All, I'm trying to write a script that searches thru a directory looking for a most recent file and then scp that file. I have the scp working, but I don't know how to browse the directory and select the most recent file. The file name includes a date & time stamp (e.g.... (3 Replies)
Discussion started by: duncan_glover
3 Replies
Login or Register to Ask a Question